I'm trying to figure out the last time a file had a certain string in it
I found this:
git rev-list --all | xargs git grep <search str> | grep <file name>
But that runs git grep against every single file that's ever been modified, then throws out all matches that aren't in the file of interest
So, it works, but it's really slow
How do I tell git rev-list to only give me revisions for a specified file?
I tried
git rev-list --all path/to/file.py
And it just gave me every file. So I tried each of these
git rev-list path/to/file.py
git rev-list -- path/to/file.py
But for both git returned help text
or if you want to know all the places that deletion was merged, too
and check the patches for whether the text was deleted or added.
git rev-listdoesn't default to theHEADcommit, you have to specify exactly where to start, that's why your later tries were failing.From comments, you're not just looking for complete removal of a string from a file, you're looking for changes removing that string from particular places in a file. For those, use
-Gnot-S.-Glooks for that pattern appearing in diffs where-Signores diffs that don't change the total number of occurrences ---Sdoes what you asked for, but not what you want.