2016-09-14 97 views
3

我打算在github上添加一些基于项目的代码,例如,添加一些适合我的项目的定制选项。维护与上游同步的分支

一个想法是分叉并创建一个分支来包含我所有的更改。每次上游有新的变化,我都会将它们重新分配给我的分支。

假设这些都是我的遥控器:

$ git remote -v 
my [email protected]:khing/myproject.git (fetch) 
my [email protected]:khing/pyproject.git (push) 
up https://github.com/upstream/project.git (fetch) 
up https://github.com/upstream/project.git (push) 

上游有三个提交:A,B,C,和我有两个额外提交:M,N

所以我想目前的树枝会像:

up: A--B--C 
my: A--B--C--M--N 

假设上游有两个新的提交d和E,我应该获取和重订(是的,我可能要解决合并冲突),所以我想这将是:

up: A--B--C--D--E 
my: A--B--C--D--E--M--N 

这是维持我自己的分支,同时保持最新的上游分支的好方法吗?

+0

抓取很好,但我不认为你需要重新绑定。否则,这是很好的。这是要走的路。 –

回答

3

是的。这就是我在“Pull new updates from original GitHub repository into forked GitHub repository”中所描述的。

由于这个问题的答案(2010年),您可以:

  • 配置总是从原来的上游回购拉

    git remote set-url origin https://github.com/upstream/project.git 
    git remote set-url --push origin [email protected]:khing/myproject.git 
    
  • 确保你总是在顶部衍合本地提交什么是牵强:
    (需要Git的2.9+六月2016年,看到 “Can “git pull” automatically stash and pop pending changes?”)

    git config pull.rebase true 
    git config rebase.autoStash true 
    

然后一个简单的git pull就足够了。

相关问题