Use git grep to locate the commit:
git grep "string" $(git rev-list --all)
The git rev-list --all makes it search the entire history of the project.
That will give an output like this:
<commit>:<path>:<matched line>
Then you can use git branch --contains to find out which branch the commit is on:
git branch --contains <commit>