[英]gitignore file pattern not working
I have dynamic directory structure like, 我有动态目录结构,
dependency
a
b
c
d e
f
g
h
I want to ignore all files under dependency folder recursively except .xml
files. 我想递归地忽略依赖文件下的所有文件,除了
.xml
文件。
I am using below pattern to achieve the same. 我正在使用下面的模式来实现相同。
dependencies/**
!dependencies/**/*.xml
But it seems it's not working for me. 但似乎对我不起作用。 It's ignoring all the files but accepting only
.xml
files which are directly inside the dependency folder, not recursively . 它会忽略所有文件,但仅接受直接位于依赖文件夹内的
.xml
文件, 而不是递归地接受 。 :( :(
I am using below environment. 我正在使用以下环境。
OS : Windows 7(64 bit) 作业系统 :Windows 7(64 bit)
Git : 2.6.1.windows.1 Git :2.6.1.windows.1
Can anyone help me? 谁能帮我?
This should work: 这应该工作:
You ignore everything but white-list the parent folders. 您忽略所有内容,但将父文件夹列入白名单。
Then you can white-list files. 然后,您可以将文件列入白名单。
dependencies
!dependencies/**/
!dependencies/**/*.xml
As I mentioned in " How do I add files without dots in them (all extension-less files) to the gitignore
file? ", there is mainly one rule to remember with .gitignore
: 正如我在“ 如何将不
gitignore
文件(所有无扩展名的文件)添加到gitignore
文件? ”中gitignore
, .gitignore
主要要记住一个规则:
It is not possible to re-include a file if a parent directory of that file is excluded. 如果排除该文件的父目录,则无法重新包含该文件。
That means, when you exclude everything (' *
'), you have to white-list folders, before being able to white-list files. 这意味着,当您排除所有内容('
*
')时,必须先将文件夹列入白名单,然后才能将文件列入白名单。
Check if this is working with git check-ignore -v -- afile
to see if it is ignored (and by which rule) or not. 检查它是否与
git check-ignore -v -- afile
以查看是否忽略它(以及通过哪个规则)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.