如何使用Git查看删除的文件?

时间:2012-03-28 19:15:09

标签: git

当我运行“git rm”时,我可以看到文件已在“git status”中删除。但是,在我运行“git log --stat”之后提交,我看到的是从文件中删除了一堆行。要推断一堆是否等于全部并不容易。我尝试传递显示重命名的选项但它似乎也不能推断删除(人们可能会认为它重命名为NULL)。看起来“--name-status”将显示带有“D”的已删除文件,但如果两个选项都通过,则“--stat”将被忽略。如何获取“git log”来显示已删除的文件?

2 个答案:

答案 0 :(得分:2)

git log --stat --summary

会给你diffstat(行改变),并在最后提到创作/删除。


示例:

commit e0d418054af3755a933805e587a02d2991e98625
Author: [author redacted]
Date:   Fri Jan 13 17:40:25 2012 -0800

    Remove jslint

 jslint         |   17 -
 jslint-all     |    2 -
 jslint.smjs.js | 4270 --------------------------------------------------------
 3 files changed, 0 insertions(+), 4289 deletions(-)
 delete mode 100755 jslint
 delete mode 100755 jslint-all
 delete mode 100644 jslint.smjs.js

答案 1 :(得分:1)

如何将git log--diff-filter=D一起使用?

--diff-filter=[ACDMRTUXB*]
    Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their
    type (i.e. regular file, symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown (X), or
    have had their pairing Broken (B). Any combination of the filter characters may be used. When *
    (All-or-none) is added to the combination, all paths are selected if there is any file that matches
    other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.