Recently I am using
git checkout dev_branch -b merge_branch
git rebase -m merge_branch master
git checkout master
git rebase merge_branch
to do a merge rebase. As the help document indicates, merge_branch is first reset to HEAD of master and then the new commits in original dev_branch is played back one by one to the new branch.
Several days later I want to find where is the "starting point" of this rebase merge. I can find the first delta commit in dev_branch using
git merge-base master dev_branch // Get an SHA_root of the common ancestor
git log --reverse -1 <SHA_root>..dev_branch // Get an SHA_delta of the first delta commit
But I don't find a way to locate where is the merged version of
git branch --contains <SHA_delta>
But find it is only in "dev_branch", not in "master_branch", though actually it has been merged.
In another word, the same commit with different parent (like the situation using cherry-pick) are with different SHA. Is there a way that git can recognize them as actually identical?
This is what git cherry
does.
In a situation where
topic
consisted of three commits, and the maintainer applied two of them, the situation might look like:$ git log --graph --oneline --decorate --boundary origin/master...topic * 7654321 (origin/master) upstream tip commit [... snip some other commits ...] * cccc111 cherry-pick of C * aaaa111 cherry-pick of A
[… snip a lot more that has happened …]
| * cccc000 (topic) commit C | * bbbb000 commit B | * aaaa000 commit A |/ * 1234567 branch point
In such cases,
git cherry
shows a concise summary of what has yet to be applied:$ git cherry origin/master topic - cccc000... commit C + bbbb000... commit B - aaaa000... commit A
Here, we see that the commits A and C (marked with
-
) can be dropped from yourtopic
branch when you rebase it on top oforigin/master
, while the commit B (marked with+
) still needs to be kept so that it will be sent to be applied toorigin/master
.