How to find the Git commit that introduced a string in any branch? (stackoverflow.com)
git log -S <whatever> --source --all
To find all commits that added or removed the fixed string
--allparameter means to start from every branch and
--sourcemeans to show which of those branches led to finding that commit.
It's often useful to add
-pto show the patches that each of those commits would introduce as well.
Versions of git since 1.7.4 also have a similar
-Goption, which takes a regular expression. This actually has different (and rather more obvious) semantics, explained in this blog post from Junio Hamano.