C E | / B D | / A
How to get the SHA of the commit A if E is the current HEAD?
A
E
HEAD
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>