git log supports two options for searching the contents of each commit’s
-S<string>— look for patches containing a fixed string. Technically, this option looks for differences in the number of occurrences of a string in a file.
-G<regex>— look for patches matching a regex.
-G option can be useful to add a word boundary character to a fixed
string. So instead of:
$ git log -S my_string
$ git log -G "\<my_string\>"
to avoid unwanted matches (like
These filtering options are best used with the
--patch option to show
the commit diff of files that contain the searched-for string/regex. To see the diff
of all files in each matching commit, use the
--pickaxe-all option too.