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

What do you mean by "version number"? It is quite common to tag a commit with a version number and then use

$ git describe --tags

to identify the current HEAD w.r.t. any tags. If you mean you want to know the hash of the current HEAD, you probably want:

$ git rev-parse HEAD

or for the short revision hash:

$ git rev-parse --short HEAD

It is often sufficient to do:

$ cat .git/refs/heads/${branch-main}

but this is not reliable as the ref may be packed.


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


This gives you just the revision.

git rev-parse HEAD

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