How do I get the hash of the current commit in Git?
To turn any extended object reference into a hash, use git-rev-parse
:
git rev-parse HEAD
or
git rev-parse --verify HEAD
To retrieve the short hash:
git rev-parse --short HEAD
To turn references (e.g. branches and tags) into hashes, use git show-ref
and git for-each-ref
.