git grep is the answer. Once for each branch name:

git grep "foo" master
git grep "foo" maint
git grep "foo" temp

Assuming that there are three branches called: master, maint, and temp.

If you want an "easier" (but not "simpler") way to scan all branches, then
on a UNIX system (I don't know Windows), you can do:

git branch | awk '{print $NF;}' | xargs -l git grep "foo"

git branch lists the names of all the branches. The "awk" writes out the
"last" column's value. This is basically because the current branch is
prefixed with a "* " which needs to be stripped out. the "xargs -l" (lower
case l, not the number 1) then invokes the command: git grep "foo"
appending the branch name after the "foo". Each output line looks something

branch_name:file_name:contents of matching line

On Thu, Feb 21, 2013 at 7:49 AM, Dale R. Worley <> wrote:

> > From: William Seiti Mizuta <>
> >
> > You can use "git grep string branch" to check if the string exists in the
> > branch.
> I think the question is, "How do you determine which branch contains a
> file that contains <string>?"
> Dale

This is a test of the Emergency Broadcast System. If this had been an
actual emergency, do you really think we'd stick around to tell you?

Maranatha! <><
John McKown

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Reply via email to