See which commit deleted a file with Git

Today I had one of those ‘Hey – where’d that file go’ moments. Turns out it’s pretty easy to find the commit that removed a file a with Git.

You can use the — option in git log to see the commit history for a file, even if you have deleted the file.

# see the changes for a file, even if it was deleted
git log -- [file_path]

# limit the output to only the last commit that touched the file
git log -1 -- [file_path]

# include some statistics, eg. how many files were deleted
git log -1 --stat -- [file_path]

Happy coding.