Yktula
Yktula

Reputation: 14809

Checking out a project's first commit with git

Is there an easy way to find the SHA1 of the first commit in a project with a long history with git?

Upvotes: 2

Views: 164

Answers (2)

Rufinus
Rufinus

Reputation: 30751

git log --reverse | head -n1

Upvotes: 2

CB Bailey
CB Bailey

Reputation: 792069

Just off the top of my HEAD, this should get one of the 'first' commits of the current branch.

git rev-list --reverse HEAD | head -1

(If the branch contiains two unrelated branches which have been merged together, it's not guaranteed which root you will get but you could use --date-order to select the oldest.)

Upvotes: 5

Related Questions