3
C    E
|   /
B  D
| /
A

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

Marc
  • 2,900
  • 3
  • 26
  • 40

3 Answers3

3

When trying to get SHA of base commit for a current branch this is useful:

git merge-base --fork-point <main branch>
Juozas Kontvainis
  • 9,461
  • 6
  • 55
  • 66
2

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>
1

You can see git log [options] and find the started commit of a specific branch.

$ git log --oneline --decorate --all --graph
Sajib Khan
  • 22,878
  • 9
  • 63
  • 73