The current git warehouse model is as follows:
upstream
|
origin
|
local copy
1
2
3
4
5
1
2
3
4
5
There are bifurcations after git fetch and merge
gitfetch
upstream code is executed after git merge
, and then git status
finds that git branch bifurcates (not after rebase
).
An error similar to the following is prompted:
Your branch and 'origin/xxx' have diverged,
and have 1 and 1 different commit(s) each, respectively.
1
2
1
2
The reason for the bifurcation is that there are two independent commits (each may have multiple commits): one from your local branch replica, and the other from the remote branch replica. (usually because another person made a submission in the same branch upstream)
An example git submission history tree:
... o ---- o ---- A ---- B origin/branch_xxx (upstream work)
\
C branch_xxx (your work)
1
2
3
4
5
1
2
3
4
5
At this time, the way to solve the bifurcation is:
On the local branch, execute:
git rebase
1
1
The GIT submission history tree after rebase is as follows:
... o ---- o ---- A ---- B origin/branch_xxx (upstream work)
\
C` branch_xxx (your work)
1
2
3
1
2
3
Rebase will prompt the same error later
The same error may occur after rebase, because you have pushed and submitted to your origin before rebase. Because rebase will rewrite the history submission record, the history submission status of your local and your origin is different, which also causes bifurcation
Git submission history tree before rebase :
... o ---- o ---- A ---- B master, origin/master
\
C branch_xxx, origin/branch_xxx
1
2
3
4
1
2
3
4
... o ---- o ---- A ---------------------- B master, origin/master
\ \
C origin/branch_xxx C` branch_xxx
1
2
3
1
2
3
At this time, you must make sure that you are in the situation described above . The solution is to force push to the upstream of your origin , and execute the following command to solve the problem:
git push origin branch_xxx -f
Similar Posts:
- Git Pull Error: Please specify which branch you want to merge with.
- Git Status Warming: Your branch is ahead of ‘origin/master’ by 1 commit…
- Conflict resolution after git error non fast forward
- Git pull does not specify an error message for the branch
- [Solved] Git pull fatal: refusing to merge unrelated histories
- Git | fatal: refusing to merge unrelated histories [How to Solve]
- error: src refspec master does not match any [How to Solve]
- Git Error: nothing to commit, working directory clean [How to Solve]
- git pull There is no tracking information for the current branch.
- error: failed to push some refs to ‘https://gitee.com/XXXX/ui-demo.git’