简体   繁体   English

如何将远程github存储库正确合并到本地

[英]How to merge remote github repos to local correctly

I am currently working in two locations and am encountering problems in terms of keeping my local repos on both machines current. 我目前在两个地方工作,在将两台机器上的本地存储库保持最新状态方面遇到了问题。 Once I have committed and pushed changes to github on one machine, if I then try to pull the repo to the other local machine I inevitably get errors. 一旦我将更改提交并推送到一台机器上,然后再尝试将存储库拉到另一台本地机器上,我不可避免地会出错。 I am sure I am doing something wrong, what is the correct procedure for achieving a seamless workflow between the two local machines in relation to my remote repos. 我确定我做错了什么,相对于我的远程仓库,在两个本地机器之间实现无缝工作流的正确程序是什么? This is in relation to both the master and branches I am working on. 这与我正在工作的主服务器和分支服务器有关。 Thanks! 谢谢!

During development you usually want to rebase your local changes onto the remote HEAD. 在开发过程中,您通常希望将本地更改基于远程HEAD。

Assuming you have no uncommitted changes locally, simply use git pull --rebase . 假设您在本地没有未提交的更改,只需使用git pull --rebase
If you do have uncommitted changes, either commit them or git stash them, then rebase and then unstash them using git stash pop . 如果您确实有未提交的更改,请提交它们或git stash它们,然后重新设置基础,然后使用git stash pop取消git stash pop它们。

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

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