在文件夹中忽略特定扩展名的gitignore文件

3
我想让git忽略所有扩展名为.ex的文件,但只有当它们在名为subf的子文件夹中时才忽略。在gitignore手册中,我读到了以下内容:
Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:

   ·   A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or
       directory "bar" anywhere that is directly under directory "foo".

然而,如果我将**/subf/*.ex放入.gitignore(在存储库基目录中),我的扩展名为.ex的文件不会被忽略!我在this线程中读到,我应该将我的排除规则添加到文件.git/info/exclude中。这对我似乎有效,但我对此感到不满,因为这不是我理解.gitignore的方式。有人能帮我理解为什么在.gitignore中放置**/subf/*.ex无效吗?谢谢!
1个回答

1
为什么不像这样简单,

 subf/*.ex

如果您期望在任何级别上都有子文件夹,

则可以这样做:

**/subf/*.ex

它对我来说正在工作


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接