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.

  • Creating initial wiki for new repositories
  • linked local repo to incorrect github account
  • GitVersion in a Jenkins Multibranch Pipeline job
  • LibGit2Sharp CheckoutPaths()
  • Interactive rebase for only my commits
  • Can not clone project from gitlab
  • How do I fetch/re-push a submodule in git?
  • Gitlab: Is it possible to create a merge request from MY fork to Another fork of the same project
  • Why does git store objects in directories with the first two characters of the hash?
  • How to pull updates from parent Git repo after forking?
  • Convert an SVN checkout to use git (git-svn)
  • How to check out most recent git tag using Ansible?
  • 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.