When trying to merge two Git branches that have diverged a lot, it's a little difficult to make sense of what happened on both sides.
Enter git merge-base--a simple built-in utility to tell you where two branches diverged. It will tell you the commit where the two branches split off:
This command will create a tag _base
that will point to where they both diverged.
You can then use git diff
, git log
, or tig to inspect changes on either side:
You can also use the --independent
flag which will show commits that can't be reached by any other. If it prints 2 commits, it means that there are changes on both sides.
If it only prints 1, it means only one side has changes.