Both Cherry-pick,revert and rebase in git use the 3-way merge strategy, and here's a look at the merge-base,ours and theirs used by these 3 methods.
Cherry-pick
If you have the following commit history, using the command git cherry-pick alt (currently branch is master), then Merge-base is the shadow commit 1,ours is the shadow commit 3,theirs is the shadow commit 2.
Revert
If there is the following commit history, using the command git revert master~2, then Merge-base is the shadow of the commit 1,ours is the shadow of the commit 3,theirs is the shadow of commit 2.
Rebase
If there is a commit history as follows, each commit adds a line to a file a, such as commit 1 writes to file a 1,commit 2 writes 2 to file A, and so on. What is merge-base,ours,theirs when using the command git rebase--onto master alt1 alt2?
When using the rebase command, GIT does 3 things like this:
1 determine what commit to rebase, here rebase commit is ALT1. Alt2. Alt1. Alt2 said from the ALT2 can be reachable to subtract from the ALT1 can also reachable the commit, here is the commit 10,commit11,commit12;
2 using an anonymous branch point to ALT2
3 Reset the ALT2 to the new base, which is the master
As shown in the following:
Then git will 10,commit commit one by one, commit rebase to the new alt2. If there is a conflict in rebase commit 10, then merge-base is the commit 6,ours is ALT2 point to the commit 5,theirs is commit 10. If commit is COMMT 10 ' (Alt2 will point to commit 10 ') after a successful commit, then rebase commit 11 If there is a conflict, merge-base is also a commit. 6,ours is commit ', theirs is commit 11. When rebase is complete, if it looks like this:
Since rebase commit 10,commit 11,commit 12 is not referenced by any branch, they will eventually be removed by Git.
Rebase has a special case as shown in:
If you run the command git rebase--onto master alt1 Alt2, the commit to be rebase should be alt2 commit 7,commit 8, commit 10, but because ALT1 (in git rebase--help , ALT1 is called upstream), which also has commit 7 and commit 8, as they do for file A, and git will only rebase commit on ALT2. 10, the corresponding merge-base will also become ALT1 on the commit 8, the final result, such as Rebase completed, the dotted box of commit 7,commit 8, commit 10 will also be removed by git.
3-way merge policies used by Cherry-pick,revert and rebase