[git] In Git, how do I figure out what my current revision is?

I just want to know what my current version number is.

This question is related to git

The answer is


This gives you just the revision.

git rev-parse HEAD

below will work with any previously pushed revision, not only HEAD

for abbreviated revision hash:

git log -1 --pretty=format:%h

for long revision hash:

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

There are many ways git log -1 is the easiest and most common, I think


This gives you the first few digits of the hash and they are unique enough to use as say a version number.

git rev-parse --short HEAD