Git log graph, display how two branches are diverging
git log
takes zero or more commits as arguments, showing the history leading up to that commit. When no argument is given, HEAD
is assumed. For your case, you want to supply the two branch heads you want to compare:
git log --graph --oneline currentbranch otherbranch
If it doesn't display too much, you can simplify this by using
git log --graph --oneline --all
which acts as if you had specified every reference in .git/refs
as the commits to display.
I had the same issue and landed here, but no answer helped me to display how two branches are diverging. Eventually I did experiment myself and found this worked.
Given branch A
and branch B
, I want to see where they diverged.
git log --oneline --graph --decorate A B `git merge-base A B`^!
Note: Don't forget there is ^!
at the end. (It excludes the parents of the commit returned by merge-base
.)
UPDATE
The one line command above isn't working in case merge base is more than one. In this case do this:
git merge-base A B -a
# e.g. output XXXX YYYY
git log --oneline --graph --decorate A B --not XXXX^ YYYY^