You want to combine flags -Sand --prettyon git log.
On the git logman page, -Spickaxe search:
-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.
. SO, git log -g -Ssearch_for_this "search_for_this".
--pretty, . , "foo" , , , , :
$ git log -Sfoo --pretty=format:'%h %an -- %s -- %ad'
bc34134 Sally Developer -- Fixed all bugs and made all clients happy forever -- Tue Jan 31 17:41:17 2025 -0500