Since MASTER is the main repo (FORK_MASTER make contributions for the MASTER repo), you should pull the changes from MASTER repo first, and then rebase the changes from FORK_MASTER on the top.
Assume the local repo develop branch commit history as below:
…---A---B develop
For MASTER repo, there are 10 commits C1
to C10
pushed. And for FORK_MASTER repo, there are 2 commits D1
and D2
pushed.
The usually workflow is pushing changes to FORK_MASTER and then create pull request to merge FORK_MASTER/develop into MASTER/develop (since the person works on the FORK_MASTER repo usually is not the administrator of the MASTER repo):
# In local FORK_MASTER repo
git remote add upstream https://github.com/user/MASTER -f
git checkout develop
git pull origin develop
git pull upstream develop --rebase
git push -f origin develop
The commit history will be:
…---A---B---C1---C2---…---C10---D1---D2 develop, origin/develop
|
upstream/develop
Now the FORK_MASTER repo is updated. You can also update MSTAER repo by creating pull request to merge FORK_MASTER/develop into MASTER/develop. Or if you have permission to push changes to MASTER repo, you can push to MASTER repo directly by git push upstream master
.
Note: when rebase commits D1
and D2
on the top of upstream/develop
, if there has conflicts, you can modify and save the conflict files manually, and then use git add .
and git rebase --continue
.