[英]Git ignore everything in directories but one file type
I have this hierarchy, full of automatically generated folders:我有这个层次结构,充满了自动生成的文件夹:
| .gitignore
| ip
| |ip1
| | |ip1.xci
| | |\other files\
| |ip2
| | |ip2.xci
| | |\other files\
| |ip3
| | |ip3.xci
| | |\other files\
| |ip4
| | |ip4.xci
| | |\other files\
...
I want to write a rule to ignore everything but the.xci files (necessary to regenerate everything else), how do I write such a rule?我想编写一个规则来忽略除 .xci 文件之外的所有内容(需要重新生成其他所有内容),我该如何编写这样的规则?
I have tried writing rules like:我尝试过编写如下规则:
ip/**/*
!ip/**/*.xci
but it doesn't work.但它不起作用。
As I have understood it, git won't look for files in directories it has ignored even if the patter would match.据我了解,即使模式匹配,git 也不会在它忽略的目录中查找文件。 Is there a way not to write a line for every file I want to keep?
有没有办法不为我要保留的每个文件写一行? As other folders will be added.
因为将添加其他文件夹。
You need to unignore directories to make git
look into them:您需要取消忽略目录以使
git
查看它们:
ip/**/*
!ip/**/*/
!ip/**/*.xci
There is .gitignore
file associated with every git repository if not just create one.如果不只是创建一个,那么每个 git 存储库都有一个
.gitignore
文件关联。
You can Ignore directories by entering the directory name into the file (with a slash appended):您可以通过在文件中输入目录名称来忽略目录(附加斜杠):
dir_to_ignore/
More information is here .更多信息在这里。
You can mention all what you want to ignore there as extension as well for files您可以提及所有您想忽略的内容作为文件的扩展名
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.