Get the commit hash of a branch

git rev-parse

  • Display metadata related to specific revisions.
    More information: <https://git-scm.com/docs/git-rev-parse>.
  • Trick copyright: tl;dr; <https://github.com/tldr-pages/tldr>

git rev-parse {{branch_name}}

click the source code to copy install git rev-parse on any operating system with command-not-found.com