
Getting a list of local git branches without using "git branch"
At some point, you may need to get a list of git branches using a script. One of the issues with using git branch
to do this, is that it can give you garbage output if you have colorized UI set up.
Instead of using a Porcelain command (like git branch
) in scripts to get the list of branches, use the following command instead
$ git for-each-ref --format '%(refname:short)' refs/heads/