If I’m looking for code changes:
git log -S <the-string>
If it’s commit messages I’m interested in:
git log --grep <the-word-or-phrase>
Sometimes I want to know “all the commits that introduced a pattern”:
git blame —- $(git grep -P -l 'the.*regex') | grep -P 'the.*regex'
This last one I use frequently enough that I wrote a little shell script for it, called "git-blep" (for "blame-grep")
———
If there’s a function name that you’re logging, then you might get mileage from
git log -L :<the-function-name>:<the-file-name>
Though that probably would not have worked in the original author’s case.