There’s two steps to see the contents of a file that has been deleted in git.
First, you need to know the tree-ish for the commit when it was deleted:
The tree-ish for the commit when it was deleted
git log -1 --pretty=%h -- the_dir/the_filename.txt
That asks for the latest log entry (
the_dir/the_filename.txt and only outputs the
`short'' commit id (--pretty=%h`). The branch is assumed to be
HEAD, but you can specify that before the
-- is needed before the filename or
git log will try to interpret it as a tree-ish.
Then simply show the content of the file in the commit immediately preceding that:
Showing the content of a file immediately before commit 'da9ccfd':
git show da9ccfd^:the_dir/the_filename.txt
^ asks for the commit immediately preceding the tree-ish it annotates for git show.