Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.gitignore negation not working

I'm using msysgit 1.9.4.

My .gitignore file, at the root of the repo, looks like this:

build/
a/b/
!a/c/d/e/**/build/

My intent is that, all build/ directories are ignored, unless they are subdirs (any depth) of a/c/d/e/. But a/c/d/e/f/build/ is still getting ignored by Git.

What am I missing here?

like image 959
ellriley Avatar asked Jan 30 '26 04:01

ellriley


1 Answers

The general rule of gitignore is simple:

It is not possible to re-include a file if a parent directory of that file is excluded.

To exclude files (or all files) from a subfolder of an ignored folder build, you need to exclude the folder first, then the files:

I have tested:

**/build/
a/b/
!a/c/d/e/**/build/     <== whitelist folder first
!a/c/d/e/**/build/**   <== then the files
like image 164
VonC Avatar answered Jan 31 '26 19:01

VonC