Instead of the method introduced here, you may use
$ git rev-parse HEAD
to get the commit SHA-1 hash ID.
If you want to get the first 8 digits only, use
$ git rev-parse HEAD | cut -c 1-8
cut -c 1-8 gives you bytes 1 to 8.
BTW: if you have tags tagging the versions, you may use
$ git describe --tags --long
to get a better string for IDs like
Here, 'v2.0' is the latest tag. '40' is the number of commits after the 'v2.0' tag and 'gdc25d60' is the first 8 digits of the commit sha-1 hash ID.