简体   繁体   中英

Pull latest changes from origin/master after push to origin/master

Currently I can push to my remote repository (from local), which updates the remote origin master branch. I can see the changes immediately in github.

If I create a new file from my local repo, add, commit and push to the remote I would like the remote to instantly receive that file after push:

local_repo
-------------
README.md
test1.txt
test2.txt # This is a new file that should appear on the remote after push

However, although Github is updated with the new file instantly, the remote repo isn't updated before I pull the latest changes:

remote_repo (after local push to remote, before remote pull)
------------
README.md
test1.txt

The remote repo shows the most recent changes after pulling from master:

remote_repo (after local push to remote, and after remote pull)
-------------
README.md
test1.txt
test2.txt

How can I have the remote automatically pull and receive the latest changes from its own master branch?

EDIT: My use case and additional details below ****************

I have a game server with many files, which lives on my cloud server (VPS). Traditionally, I would update / add new files by uploading via FTP. I'm looking to replace that workflow with version control.

  • remote_repo is where my game server files live
  • local_repo is where I make updates and modifications to those files, add, commit and push them to "remote origin"
  • I originally thought, by pushing from local_repo to remote, my remote_repo would be updated with the newest changes
  • That is not the case and based on the comments (thanks @TTT), it seems like I need to pull the latest changes into remote_repo, as this repo was never "pushed-into". I was actually "pushing-to" remote origin which is different from my remote_repo

How can I have remote_repo receive the latest changes from remote origin without manually going into the repo and pulling after every push?

you can create a shell script that does:

git push
git fetch

and run it instead of git push

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM