is there a possibility to get all branches of an git repository with thier head commit.
If I have the following repository:
* b562239 (HEAD -> master) lastCommit
* 3828834 (seccondBranch) seccond Commit
| * 3f6fdf6 (firstBranch) branchCommit
|/
* b051ccd init repo
I want to get a list like that:
master b562239
seccondBranch 3828834
firstBranch 3f6fdf6
The plumbing tool for refs is git for-each-ref
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With