Reputation: 143
I have the following folders:
../A/A/bin/
../A/A.source/Bin/
../B/B/bin/
../B/B.source/Bin/
Folders that match pattern *.source/Bin/ ("../A/A.source/Bin/" "..B/B.source/Bin/") should not be ignored.
I've tried to achieve this by different ignore rules, but in all cases, it either ignores every bin folder and its content or ignore nothing at all. I've looked through gitignore Documentation, but to no avail.
How can I achieve that?
EDIT: I tried these rules:
# everything is ignored
bin
!*.source/bin
bin/
!*.source/bin/
# everything is allowed
bin/*
!*.source/bin/*
bin/
!*.source/bin/
bin/*.*
!*.source/bin/*.*
Upvotes: 1
Views: 672
Reputation: 94417
As said in the docs:
If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore file itself. Otherwise the pattern may also match at any level below the .gitignore level.
(Emphasize mine — phd)
This means the pattern !*.source/bin/
is only applied to the current directory but not subdirectories. To make the pattern works deeper in the directory hierarchy use **/
. So your patterns should be:
bin/
!**/*.source/bin/
Upvotes: 3