Last Updated: February 25, 2016
·
438
· Lorin Hochstein

git sha shortcut

When I'm working in a git repository, I often want to get the current sha. You can use the rev-parse command for this:

$ git rev-parse HEAD
7fd1a60b01f91b314f59955a4e4d4e80d8edf11d

I like to define a "sha" alias in my ~/.gitconfig:

[alias]
        sha = rev-parse HEAD

Then I can just do:

$ git sha
7fd1a60b01f91b314f59955a4e4d4e80d8edf11d