Show all files deleted since Git commit

20 Nov 2020 in TIL

Whilst working on my TIL page I cleared out a few old blog posts that fit in to the TIL category but weren’t really relevant any more.

Before publishing, I wanted to check which posts I’d removed. Fortunately this site is stored in a git repo and I could use git diff to show which files had been deleted.

I use git diff with --diff-filter D to show only the deleted files. I use --name-only here to show only the deleted filename.

Replace committish with the git ref that you want to compare against:

git diff --name-only --diff-filter D <commitish> HEAD

For example, to show all files deleted since the last push:

git diff --name-only --diff-filter D origin/main HEAD

This will show output similar to the following:

❯ git diff --name-only --diff-filter D origin/main HEAD