Git Short Commit ID
In a git repository, every commit is associated with an SHA1 hash of 160 bits, or 40 characters when represented in hexadecimal. This can be abbreviated to make it easier to reference.
To get a list of hashes for changes:
$ git rev-list HEAD
To get the full hash of the latest commit:
$ git rev-parse HEAD
a657cd1e291dc69b5c491c5c1c6dbfe600ffaafd
To get the short hash (default length 7):
$ git rev-parse --short HEAD
a657cd1e
To get the short hash with a non-default length:
$ git rev-parse --short=4 HEAD
a657c
The length can be more than specified if it is non-unique for a repo
To get the branch name:
$ git rev-parse --abbrev-ref HEAD
master