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

我知道git存储何时文件被删除的信息,我可以检查单个提交以查看哪些文件已被删除,但是有没有一个命令可以在存储库的使用寿命中生成每个已删除文件的列表?


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

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.


If you're only interested in seeing the currently deleted files, you can use this:

git ls-files --deleted

if you then want to remove them (in case you deleted them not using "git rm") pipe that result to xargs git rm

git ls-files --deleted | xargs git rm
链接地址: http://www.djcxy.com/p/18942.html

上一篇: 脱字符(^)字符是什么意思?

下一篇: 我怎样才能列出所有删除的文件在git仓库?