How to .gitignore files recursively

I am trying to avoid the following pattern in my .gitignore file.

 MyPrject/WebApp/Scripts/special/*.js MyPrject/WebApp/Scripts/special/*/*.js MyPrject/WebApp/Scripts/special/*/*/*.js MyPrject/WebApp/Scripts/special/*/*/*/*.js MyPrject/WebApp/Scripts/special/*/*/*/*/*.js MyPrject/WebApp/Scripts/special/*/*/*/*/*/*.js MyPrject/WebApp/Scripts/special/*/*/*/*/*/*/*.js 

We tried:

 MyPrject/WebApp/Scripts/special/**.js MyPrject/WebApp/Scripts/special/**/*.js 

This, however, did not work. This is git on Windows. Is there a more concise way to do this without repeating anything?

+45
git gitignore
May 14 '13 at 18:54
source share
2 answers

According to git 1.8.2 this is:

 MyPrject/WebApp/Scripts/special/**/*.js 

Should work in accordance with this answer . It also works for me on Windows 7 using Sourcetree 1.6.12.0 and the git version that it installs (1.8.4-preview20130916).

To gitignore each file and folder in a directory recursively:

 MyPrject/WebApp/Scripts/special/** 
+43
Jan 02 '15 at 12:09
source share

The following gitignore manual page:

[...] git treats the template as a shell suitable for fnmatch (3) consumption with the FNM_PATHNAME flag: wildcards in the template will not match / in the path.

So, this clearly means that there is no way to specify a certain number of directories between two lines, for example between special and js .

However, you can have a .gitignore file for each directory, so maybe in your case the following content

 *.js 

in the next place

 MyPrject/WebApp/Scripts/special/.gitignore 

would be enough?

+15
May 14 '13 at 19:29
source share



All Articles