Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.gitignore: How do I ignore nested directories?

Tags:

git

gitignore

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?

like image 325
artagnon Avatar asked Oct 02 '12 05:10

artagnon


People also ask

Can Gitignore ignore folders?

gitignore is a plain text file in which each line contains a pattern for files or directories to ignore. It uses globbing patterns to match filenames with wildcard characters. If you have files or directories containing a wildcard pattern, you can use a single backslash ( \ ) to escape the character.

Can Gitignore files be nested?

You can nest gitignores in a project to have per directory ignore files. e.g. Now a/b/. gitignore can handle any ignoring in subdirectory b .


1 Answers

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.

like image 64
Chin Huang Avatar answered Nov 04 '22 01:11

Chin Huang