How to get branch hash using git command
git show -s --format=&quot;%H&quot; &lt;HEAD or Branch Name&gt;

-s supressess the diff output
--format=&quot;%H&quot; specifies that only the hash should be shown.
See man git-show for more details.