Can git be made to ignore nested .gitignore files when computing ignores?
I wanted to track some files ignored by a bunch of repos into a single repo.
Here’s an example layout:
- How to ignore files which is already versioned by git?
- How to convert data from .gitignore into list of regexp-es in Perl
- .gitignore ignoring a file even though no rules specify it
- how can I use git to track folder structure?
- What should I include in the .gitignore file for Swift playgrounds?
- How to exclude file only from root folder in Git
. +-- .git +-- .idea |-- .gitignore |-- proj1 | +-- .git | |-- .gitignore | |-- foo | | |-- foo.iml | |-- bar.c | |-- proj1.iml |-- proj2 +-- .git |-- .gitignore +-- bar |-- foo.c |-- proj2.iml
- the root-level repo to include all *.iml files, while each sub-repo individually ignores them
- all the repos to be independent (the projects don’t depend on the root, and can be manipulated separately)
- this folder structure to be maintained
One Solution collect form web for “Can git be made to ignore nested .gitignore files when computing ignores?”
The title of the question and the detailed description seem to ask slightly different questions…
With regards to the title of the question: to exclude nested .gitignore files, but not the root .gitignore itself, add the following line to your root .gitignore file:
(this will only ignore those .gitignore files that are nested at least one folder level deep)
Alternatively, if you only want to ignore .gitignore files in direct child folders, but still want to include all .gitignore files in indirect (i.e., 2nd level, 3rd level,…) sub-folders use: