Search git branch names using command line

S

Looking for a particular branch, and `git branch -a` returns a LOT of branches?
If on Windows, you could use the Search feature in cmder (you’re using cmder, right?)

Or on mac, cmd+f and then search the outputted text…

OR you could use one of these two approaches:

1)
git branch takes a `–list` argument , which in turn takes a search arg.
Example:

git branch -a --list *something*

Will return only the branches containing the word “something” (note the wildcard character)

2)
The alternative, if in bash / bash compatible terminal (git bash / cmder etc… on Windows – normal Command Prompt won’t work – unless you’ve got bash extensions installed) is to pipe the result to grep:

git branch -a | grep something

Both methods here will yield the same results.

Side note:
-a shows all local and remote branches
-r shows only remote branches