Suppose I have a file bar.cpp
that I have committed into git. Sometime in the past, I used to have a foo
in that file.
QUESTION
How do I find all git revisions of bar.cpp
which contain that string foo
?
NOTE
A command-line solution would be great.
Can use the pickaxe
git log -S foo bar.cpp
and if you want the diffs
git log -p -S foo bar.cpp
More info
-S<string> Look for differences that introduce or remove an instance of <string>. Note that this is different than the string simply appearing in diff output; see the pickaxe entry in gitdiffcore(7) for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With