如何保持forked repo同步到原始repo

时间:2017-01-11 12:27:59

标签: git github open-source

Github说,"This branch is 10 commits ahead, 8 commits behind xyz:master"

如何与主人合作?

2 个答案:

答案 0 :(得分:2)

master拉入您的分支(say, feature)然后解决" 8提交"。如果您将featuremaster合并,那么" 10提前提交"会解决的。

# merge 'master' into 'feature' branch (solve '8 commits behind')

$ git fetch
$ git checkout feature 
$ git pull origin master         # pull latest commits of master
$ git push origin HEAD           # update remote/feature

# merge 'feature' into 'master' branch (solve '10 commits ahead')

$ git checkout master            # checkout 'master'  
$ git pull origin master         # sync with origin/master
$ git pull origin feature        # pull latest commits of your branch 'feature'
$ git push origin master         # push to remote/master

答案 1 :(得分:-2)

将两个分支合并在一起