.gitignore: How do I ignore nested directories?

2019-06-14 21:42发布

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?

标签: git gitignore
2条回答
你好瞎i
2楼-- · 2019-06-14 22:12

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/

If you put this pattern in your top-level .gitignore file, then it will match in all directories under the top directory.

查看更多
贪生不怕死
3楼-- · 2019-06-14 22:15

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.

查看更多
登录 后发表回答