Github上fork之后如何保持同步(Windows环境)

来源:互联网 发布:怎么注销淘宝卖家账户 编辑:程序博客网 时间:2024/05/19 20:46

我们会去fork别人的一个项目,这就在自己的Github上生成了一个与原作者项目互不影响的副本,自己可以将自己Github上的这个项目再clone到本地进行修改,修改后再push,只有自己Github上的项目会发生改变,而原作者项目并不会受影响,避免了原作者项目被污染。但是如果原作者在不断更新他的项目,如何也让自己Github上的也跟着同步?这里需要借助在windows下安装github出现的一个工具Git Shell,以前一直不知道它的用处,这次体会一下。

1)进入本地项目目录,输入 git remote -v:


篮框内的url是我Github上的项目,红框内的url是原作者项目。如果没有upstream,即没有原作者项目的url,你需要自己添加:$ git remote add upstream <原作者项目的URL>

2)将原作者项目更新的内容同步到我的本地项目(不是我Github网上的项目):

a) Fetch the branches and their respective commits from the upstream repository. Commits to master will be stored in a local branch, upstream/master 


(注意:upstream 不要忘带了哦)

b) Check out your fork's local master branch.


c) 接下来就是合并这两个分支,将原作者项目的修改同步到自己这里(注意还是指本地项目,不是自己Github空间里的项目)。Merge the changes from upstream/master into your local master branch. This brings your fork's master branch into sync with the upstream repository, without losing your local changes.


至此我的本地项目已经于原作者项目同步了。

   转载自

http://blog.csdn.net/bluecloudmatrix/article/details/41176373

   http://www.tuicool.com/articles/6vayqen

0 0
原创粉丝点击