2020-03-19

git notes

git: find which commit deleted a line


Git is wonderful, but "git blame" does not show lines that have been deleted.

If you know the file where the line used to be, there is a very easy way to find the SHA1 of the commit that deleted the line:

$ git log -p PATH_TO_FILE

Then, just search for the line in question. For example, if the line contained the test "foo_bar_blatz", just search for that in the pager. Once you find the place in the diff where the line was deleted, scroll up to the diff header find the SHA1.

No comments:

Post a Comment