simplest way to get the SHA of an arbitrary git object?

I want a git command that simply outputs the SHA of an arbitrary object (commit, tree, blob, whatever). Basically:

$ git sha HEAD
$ git sha master^:CHANGELOG

…and so forth. This should be the simplest thing in the world, but I can’t figure out a good way of doing it. I don’t mind using an alias to a complex, option-laden git command, but it seems like I must just be missing a really simple dereference command that git must surely use under the hood all the time.

  • Create revision per feature branch
  • Viewing git filters output when using meld as a diff tool
  • Planning repository layout for git migration
  • How to remove git hooks
  • Client denied by server configuration while trying to use git-http-backend.exe
  • How to `git add` non-recursively?
  • How to open Github for Windows' Git Shell on right click?
  • gitolite: default remotes for new repository
  • Eclipse Neon eGit Integration gives Exception 401 Authorization Required
  • remove all binary files recursively from git repo and commit history
  • Git branch diff into one new commit
  • How to fast track branch after pull request in Github
  • One Solution collect form web for “simplest way to get the SHA of an arbitrary git object?”

    For the purposes you have given, your git sha is actually git rev-parse.

    % git rev-parse HEAD
    % git rev-parse origin/pu^:Documentation/RelNotes-1.7.1.txt
    Git Baby is a git and github fan, let's start git clone.