Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I list all the deleted files in a Git repository?

Tags:

git

I know Git stores information of when files get deleted and I am able to check individual commits to see which files have been removed, but is there a command that would generate a list of every deleted file across a repository's lifespan?

like image 250
Toby Avatar asked May 16 '11 13:05

Toby


People also ask

Can you see deleted files on GitHub?

If you have committed the deletion and pushed it to GitHub, it is possible to recover a deleted file using the GitHub Web UI. GitHub lets you browse the commit history and explore the project at any point in history, which then allows you to view and download any file.

Does git diff show deleted files?

You can use git diff --name-status, that will show you files that where added, modified and deleted.

Can we recover deleted files from git?

You can restore a deleted file from a Git repository using the git checkout command. If you do not know when a file was last deleted, you can use git rev-list to find the checksum of the commit in which that file was deleted. Then, you can check out that commit.


2 Answers

git log --diff-filter=D --summary 

See Find and restore a deleted file in a Git repository

If you don't want all the information about which commit they were removed in, you can just add a grep delete in there.

git log --diff-filter=D --summary | grep delete 
like image 150
I82Much Avatar answered Sep 23 '22 07:09

I82Much


This does what you want, I think:

git log --all --pretty=format: --name-only --diff-filter=D | sort -u 

... which I've just taken more-or-less directly from this other answer.

like image 25
Mark Longair Avatar answered Sep 23 '22 07:09

Mark Longair