On his blog, Philip Potter described something he calls “the git pickaxe”, a way to finding commits that contained a specific word. It uses git log
‘s -S
option to search for specific string:
-S<string>
Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intended for the scripter’s use.
It is useful when you’re looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being
Usage:
git log -p -S keyword
To limit searching to only one file, specify the path to it:
git log -p -S keyword /path/to/file.ext
Handy!