I need to retrieve shortened commit names for specific git branches. These are usually 7-digit hexadecimal numbers, and they are used by some systems (including the Heroku COMMIT_HASH environment variable) to identify a specific commit.
There are several ugly ways to get an abbreviated commit name, including:
$ git log -1 --oneline | awk '{ print $1 }' d4377e3 $ git describe --always --match '' d4377e3
Is there a cleaner way to get this value?
source share