git .gitignore:如何忽略嵌套目录?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12685134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.gitignore: How do I ignore nested directories?
提问by artagnon
I have the following directory structure:
我有以下目录结构:
test/a
test/b/c
test/a/b/Ouput
test/c/d/e/Output
test/f/Output
I want to ignore all the "Output" directories under "test". I tried test/**/Output
, but it didn't work. What am I doing wrong?
我想忽略“测试”下的所有“输出”目录。我试过了test/**/Output
,但没有用。我究竟做错了什么?
采纳答案by Chin Huang
You said you want the Output/
pattern to match only under the test/
directory, so in the test/
directory, create a .gitignore
file with the contents:
你说你希望Output/
模式只在test/
目录下匹配,所以在test/
目录中,创建一个.gitignore
包含内容的文件:
Output/
If you put this pattern in your top-level .gitignore
file, then it will match in alldirectories under the top directory.
如果将此模式放在顶级.gitignore
文件中,那么它将在顶级目录下的所有目录中匹配。
回答by Leszek Jasek
Since version 1.8.2(March, 8th 2013), git supports ** in .gitignore
files, so using test/**/Output/
will ignore only Output sub-directories under test directory.
从1.8.2 版本(2013 年 3 月 8 日)开始,git 支持.gitignore
文件中的** ,因此使用test/**/Output/
将仅忽略 test 目录下的 Output 子目录。