Git – “blame” a deleted line
Solution
If you know the contents of the line:
$ git log -S <string> path/to/file
which shows you commits that introduced or removed an instance of the given string.
There’s also:
$ git log -G <regex> path/to/file
which does the same thing with regular expressions.
Alternatively you can use:
$ git blame --reverse <sha1-commit-hash>..HEAD path/to/file
to see the latest revision in which the line existed.
We transform challenges into digital experiences
Get in touch to let us know what you’re looking for. Our policy includes 14 days risk-free!
Free project consultation