How can I blame a deleted file in Git?

git blame

git blame works when providing a commit reference that contains the file. Find the most recent one with log:

$ git log -2 --oneline -- example/path/file.txt

 fffffff deleting file.txt
 eeeeeee Last change to file.txt before deleting.

Then blame the parent commit:

$ git blame eeeeeee -- example/path/file.txt

git gui blame

git gui blame won’t work this way, however. A work around is to browse the repository at the last commit that contained the file, then from the GUI select the file and launch the blame viewer:

$ git gui blame eeeeeee example/path/file.txt

(Note: Use log -2 and eeeeeee instead of fffffff^ because git gui blame can not handle fffffff^:example/path/file.txt)

Leave a Comment