Last Updated: February 25, 2016
· laughedelic

List git branches

If you need to enumerate branches in a shell-script, git branch sucks: you need to cut, remove a star, etc.
Here is better solution:

git for-each-ref refs/heads/ --format='%(refname:short)'

Took from Stack Overflow question: How can I get a list of git branches, ordered by most recent commit?.

See git-for-each-ref man page for more options.