git branch - Git find the head commit of all branches
one text
Solution:
git for-each-ref --format='%(refname:short) %(objectname:short)' refs/heads
for the exact output you wanted.
Also worth noting, git branch -v
(or -vv
for even slightly more verbose) will list all branches with the commit hash their tip points to, but in a much verbose way, since it also features info about remote branches association / last commit message.
Example output of a branch with -v
:
development f06f99b5c4 [behind 1] <commit message of commit f06f99b5c4>
Example output of a branch with -vv
:
development f06f99b5c4 [origin/development: behind 1] <commit message of commit f06f99b5c4>
Source