How to find the hash of branch in Git?

Question:

Given a local / remote branch name, how could I get the hash of the commit that this branch points to?

Answer:

The command git rev-parse is your friend, e.g.:

… or for a remote-tracking branch:

This command is generally very useful, since it can parse any of the ways of specifying branch names in git, such as:

… etc.

Leave a Reply