Getting the last commit hash in Git

by Trevor Turk

Getting the last commit id (or hash or sha or whatever it’s called) is a bit more tricky than I expected:

git log master -n 1 --pretty=format:%H