[英]How to get the git log of which files were deleted/modified?
I could parse git log -p --pretty=format:%H
but this also includes the content of the files. 我可以解析git log -p --pretty=format:%H
但这也包括文件的内容。
Is there any option I could pass to git log
that would return less characters than the command above but would still allow me to figure out whether at least 1 file was deleted or modified for each commit? 有什么我可以传递给git log
选项,它返回的字符数比上面的命令少,但仍然可以让我确定每次提交是否删除或修改了至少1个文件?
You could use the --numstat
option: 您可以使用--numstat
选项:
Similar to
--stat
, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly. 与--stat
相似,但是以十进制表示法和路径名显示添加和删除的行数,不带缩写,以使其对计算机更友好。 For binary files, outputs two-
instead of saying0 0
. 对于二进制文件,输出两个-
而不是说0 0
。
So it would be: 因此它将是:
git log --pretty=%H --numstat
If you're not interested in the exact number of lines, you can use the --name-status
option: 如果您对确切的行数不感兴趣,可以使用--name-status
选项:
Show only names and status of changed files. 仅显示更改文件的名称和状态。
git log --pretty=%H --name-status
At that point you can simply parse the M
and D
statuses for modified and deleted files. 此时,您可以简单地分析已修改和已删除文件的M
和D
状态。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.