Home > Net >  Git - Find code changes with a specific comment in code
Git - Find code changes with a specific comment in code

Time:11-26

I need to find all git commits, that deleted specific comments in the code like:

// Revision

I tried git log -S'// Revision' but this gives me an error: fatal: ambiguous argument 'Revision'': unknown revision or path not in the working tree.

Guess this needs some kind of escaping?!

Is there a way to give me a list of all commits where the search string got removed and also an easy way to see the whole diff for each commit?

CodePudding user response:

Try to use git log --diff-filter=D -p -S "// Revision"

--diff-filter=D: selects only files that are removed
-p: Generate patch. That option gives the diff result to the search.
-S "string": famous git pickaxe, search for a string in all commit files and return the commit that contain the string.
The result should be the diff for the files he found the "// Revision" string, and that string got removed.

  •  Tags:  
  • git
  • Related