简体   繁体   English

推送到 origin/master 后从 origin/master 拉取最新更改

[英]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.我可以立即在 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:然而,虽然 Github 会立即更新为新文件,但在我提取最新更改之前,远程仓库不会更新:

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:远程 repo 显示从 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?我怎样才能让远程自动从它自己的 master 分支中拉取和接收最新的更改?

EDIT: My use case and additional details below ****************编辑:我的用例和下面的其他详细信息 ****************

I have a game server with many files, which lives on my cloud server (VPS).我有一个包含许多文件的游戏服务器,它位于我的云服务器 (VPS) 上。 Traditionally, I would update / add new files by uploading via FTP. I'm looking to replace that workflow with version control.传统上,我会通过 FTP 上传来更新/添加新文件。我希望用版本控制替换该工作流。

  • remote_repo is where my game server files live remote_repo是我的游戏服务器文件所在的地方
  • local_repo is where I make updates and modifications to those files, add, commit and push them to "remote origin" local_repo 是我对这些文件进行更新和修改、添加、提交并将它们推送到“远程源”的地方
  • I originally thought, by pushing from local_repo to remote, my remote_repo would be updated with the newest changes我原本以为,通过从 local_repo 推送到 remote,我的 remote_repo 会更新为最新的更改
  • 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".事实并非如此,根据评论(感谢@TTT),我似乎需要将最新的更改拉入 remote_repo,因为这个 repo 从未被“推入”。 I was actually "pushing-to" remote origin which is different from my remote_repo我实际上是在“推送”远程源,这与我的 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?我怎样才能让 remote_repo 从远程源接收最新的更改,而无需手动进入 repo 并在每次推送后拉出?

you can create a shell script that does:您可以创建一个 shell 脚本来执行以下操作:

git push
git fetch

and run it instead of git push并运行它而不是 git 推送

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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