
1 zerotty OP 我想把自己fork的那个版本更新到最新版,然后再在上面做修改。我该怎么弄啊? |
2 darkyoung Nov 29, 2011 把别人的版本做一个branch,然后merge过来 |
3 icyflash Nov 29, 2011 |
4 ywjno Nov 29, 2011 用remote从远端获取最新代码,然后本地merge一下就ok了 |
5 zhen9ao Nov 29, 2011 从别人项目那里利用remote将更新pull过来,然后再利用remote将更新了的代码push到自己的库中 |
6 benzheren Nov 30, 2011 推荐一个适合和github一起用的好工具: http://defunkt.io/hub/ |
7 ashchan Nov 30, 2011 假设你fork的项目原始地址是http://github.com/abc/rep.git, 你自己的是http://github.com/you/rep.git $ git add remote upstream http://github.com/abc/rep.git # 你本地的origin应该跟了自己的remote,前且假设当前本地branch是master。 $ git fetch upstream $ git merge upstream/master # merge可能会有冲突,手工解决掉并commit $ git push origin/master # push到你自己的fork上 然后向原始项目提交一个pull request。 |
8 ashchan Nov 30, 2011 如果要先更新再修改提交,并假设本地已经做了修改,则第一步不变,加原始库为upstream(名字你随便取,无所谓的,只要不是origin就行) $ git stash # 把你的修改先暂存下来,假设没有commit过,有的话会复杂一点,就不如直接用上面的方法 $ git pull upstream/master # 既然没有commit过,这里会直接fast forward $ git stash pop stash@{1} # 把暂存的修改拿回来 $ git add . & git commit -m "commit msg" 最后两步一样。 |
9 ashchan Nov 30, 2011 如果不打算向原项目提pull request,只是想不断更新他的,就一直用第一种方式。不过随着你自己的修改越来越多,起冲突的机会会越来越多。hope this helps. |
11 zerotty OP 谢谢各位的帮忙,已经搞好了! |
12 riku Jan 5, 2012 我觉得用 git rebase 是不是更好点? |