Reputation: 3005
How can I ignore a certain filetype only in one directory and its sub-directory?
To explain what I mean imaging the following setup
I want to be able to do is tell git (using .gitignore file) to ignore *.iml but only under the directory foldtertoignore.
I was thinking this would work
foldertoignore/*.iml
But that only found ignoreme1.iml not ignoreme2.iml
I know how to tell it to ignore *.iml except for a specific directory. This is the reverse of that. Any thoughts?
Upvotes: 10
Views: 3284
Reputation: 265231
.gitignore
rules are applied recursively from the containing directory. Simply create the file foldertoignore/.gitignore
with *.iml
as contents.
>>foldertoignore/.gitignore echo '*.iml'
git add foldertoignore/.gitignore
git commit -m 'Ignore .iml files in foldertoignore and its subfolders'
Upvotes: 8
Reputation: 301147
You can try this:
/foldertoignore/**/*.iml
It may or may not work depending on fnmatch implementation in your OS I suppose. Alternative is:
*.iml
!/anotherdir/*.iml
!/*.iml
Upvotes: 1