Search code examples
gitbranchgit-commitsha

How to get the SHA of the base commit a branch is started from?


C    E
|   /
B  D
| /
A

How to get the SHA of the commit A if E is the current HEAD?


Solution

  • If finding the common ancestor of the branches C and E is what you need, then:

    git merge-base <hash of commit C> <hash of commit E>