git blame is great for modified and added lines, but how can I find when a line that existed in a specific previous commit was eventually deleted. I’m thinking bisect, but I was hoping for something handier.
(Before you ask: in this case, I just did a git log -p and searched through for the code line and (a) some idiot had just deleted the vital line in the previous commit and (b) I was that idiot.)
If you know the contents of the line, this is an ideal use case for:
which shows you commits which introduce or remove an instance of that string. There’s also the
-G<regex>which does the same thing with regular expressions! Seeman git-logand search for the-Gand-Soptions, or pickaxe (the friendly name for these features) for more information.The
-Soption is actually mentioned in the header of thegit-blamemanpage too, in the description section, where it gives an example usinggit log -S....