Show Diff Of Deleted File In Git

If you have a deleted file in your current git status you can't use diff to see the content of the file.

Instead, you need to use the following syntax to show the file at a specific commit:

git show COMMIT:FILE

For example, to show the file at the current branch HEAD.

git show HEAD:some/deleted/file.txt

This shows the content of the file before it was deleted.

If you did commit the deletion change then you can either look at the file relative to the HEAD position.

git show HEAD~1:some/deleted/file.txt

Or, the specific sha where the file is known to exist.

git show adb96f09aa92ba0c8b3539c281000f3e7d838a07:some/deleted/file.txt

Read more about finding the relevant place in the git repo on the gitrevisions manual page.

Add new comment

The content of this field is kept private and will not be shown publicly.