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
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
Hi Trevor,
Just out of curiosity, what do you need this for? Because as I'm sure you know, this can be referred to as HEAD in other git commands.
/Jacob
I used it for this: http://trevorturk.com/2010/12/23/deploy-to-heroku…
Yes, I see.
Looks like rev-parse can be used as well:
git rev-parse HEAD