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

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


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.

Tags:

Git