简体   繁体   English

根据文件扩展名过滤 git diff-tree 的 output

[英]Filter output of git diff-tree based on file extension

git diff-tree --no-commit-id --name-only -r $CI_COMMIT_SHORT_SHA

gives me the list all the files that were committed for that SHA.给了我为那个 SHA 提交的所有文件的列表。

I am looking for a way to get a list of files with only.xml or.html extensions.我正在寻找一种方法来获取仅包含 .xml 或 .html 扩展名的文件列表。

I checked the documentation page - here and couldn't see any option.我检查了文档页面 - 在这里,看不到任何选项。

Any help is greatly appreciated.任何帮助是极大的赞赏。

You can use -- <path> [<otherpath>...] for this:您可以为此使用-- <path> [<otherpath>...]

git diff-tree --no-commit-id --name-only -r $CI_COMMIT_SHORT_SHA -- *.xml *.html

Be sure to put it at the end of the command, with no options behind it, since git will treat anything past it as paths.确保将它放在命令的末尾,后面没有选项,因为 git 会将超过它的任何内容视为路径。

Doc from the git log page here , but this is usable for a lot of display commands.来自 git 日志页面的文档here ,但这可用于许多显示命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM