[英]How to filter git diff based on file type?
Is there an option to restrict git diff
to show only a given set of file types?是否有一个选项可以限制
git diff
只显示一组给定的文件类型?
By types I mean only regular files, symlinks, submodules, etc, as listed non exhaustively in the description of --diff-filter
.我所说的类型仅指常规文件、符号链接、子模块等,如
--diff-filter
的描述中未详尽列出的那样。
I am particularly interested in getting a diff containing only regular files.我对获取仅包含常规文件的差异特别感兴趣。
Note that this question is not the same as How to filter git diff based on file extensions?请注意,此问题与如何根据文件扩展名过滤 git diff 不同?
EXAMPLE : Suppose I have this output示例:假设我有这个 output
git diff --raw HEAD^^ HEAD
:100644 100644 8e994d8 c79147d M lib/esq.txt
:000000 120000 0000000 daee357 A lib/file
where lib/file
is a symlink.其中
lib/file
是符号链接。
Is there some option to pass to git diff
to exclude the symlink from the output, or do I have to filter the output outside of Git by testing the modes? Is there some option to pass to
git diff
to exclude the symlink from the output, or do I have to filter the output outside of Git by testing the modes?
Thanks谢谢
If you are able to create a list of the files (with find, for example), then you could use xargs.... hopefully it should work:如果您能够创建文件列表(例如使用 find),那么您可以使用 xargs .... 希望它应该可以工作:
find ./ whateverfilter | xargs git diff
That should work.那应该行得通。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.