Marc
Marc

Reputation: 3070

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?

Upvotes: 3

Views: 3203

Answers (3)

Juozas Kontvainis
Juozas Kontvainis

Reputation: 9597

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

git merge-base --fork-point <main branch>

Upvotes: 3

user7605325
user7605325

Reputation:

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>

Upvotes: 2

Sajib Khan
Sajib Khan

Reputation: 24174

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

$ git log --oneline --decorate --all --graph

Upvotes: 1

Related Questions