I have the following directory structure:
project
modules
some-company-foo
different-company-bar
mycompany-a
mycompany-b
mycompany-c
How can I ignore all the files in modules, except those that start with mycompany
?
Similar to git ignore all except subfolder, but using a wildcard. I don't want to have to maintain a list of every mycompany-...
folder in .gitignore
.
Based on other answers, I've tried creating modules/.gitignore
with the following contents:
/*
# Do not ignore mycompany modules
!/mycompany*
And modules
isn't mentioned in project/.gitignore
at all.
But this doesn't work. Eg,
git add /Users/mike/Documents/project/modules/mycompany-faq/questions/somefile.md
Fails with:
The following paths are ignored by one of your .gitignore files:
modules/mycompany-faq/questions/somefile.md
Use -f if you really want to add them
How can I ignore all the files in modules
, except those that start with mycompany
?