How do I search for branch names in Git?

git branch -a | grep selector

Or

git branch -r | grep selector

-a shows all local and remote branches, while -r shows only remote branches.


git branch --all | grep <id>

Git 1.7.8 offers a solution without using grep:

git branch --list <pattern> and in bash git branch --list '<pattern>' with quotes around pattern.

This works with wildcards (*) as well, so you can do use git branch --list *<id>* to find your branch.

This filters the list of branch names returned by the rest of your git branch command (for example, local branches only by default, all branches with git branch -a --list <pattern>, etc.).

Tags:

Git

Search