I've got a script that needs to reference the initial commit in a repository. git has the special reference HEAD
, but doesn't have the corresponding TAIL
. I cannot find anything in git help rev-parse
that would seem to help me.
Here's what I'd like to do:
git show TAIL
Here's one option I have:
git show `git log --reverse | if read a commit ; then echo $commit ; fi`
That's pretty hacky and depends on the output of git log not changing.
Right now I just tag the initial commit and use that as my refspec. However, I'd like to release a general tool, so that's not a great option.
git rev-list HEAD | tail -n 1
andgit rev-list --max-parents=0 HEAD
are not returning the same hash value for me. The one using the--max-parents=0
is in fact getting the initial commit though. Just thought I would point out that the latter seems more reliable. – Uranalysis