How do I search for branch names in Git?

I'd like to find a specific branch, and I know that its name would contain a specific substring (the id of the issue from our bug tracker), but I don't know the whole name of the branch (this is what I want to find out).

How can I search for this branch?


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.).


git branch -a | grep selector

Or

git branch -r | grep selector

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