Get the short Git version hash

Try this:

git rev-parse --short HEAD

The command git rev-parse can do a remarkable number of different things, so you'd need to go through the documentation very carefully to spot that though.


You can do just about any format you want with --pretty=format:

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