Git ignore list of all files in subdirectory, recursively
My software project is modular. Some files are committed by the developer in designated subdirectories, others are uncompressed to provide a runtime environment (web resources) for development and do not need to be executed.
- webapp - common (provided) - error (provided) - secure - admin (provided) - audit (provided) - ftt (provided) - WEB-INF (to ignore)
I want to ignore everything under webapp except all files in
and its subdirectories.
But Git still ignores ftt.
I expect these directories to contain only files
. But I cannot know what will happen in the future (like gif, pdf, etc.)
How can I tell Git to whitelist in
and ignore everything else in
From my research, I've found that this is not possible without listing each specific subdirectory and file template.
[Add] after @DevDonkey comment I tried to clean up the whole gitignore file and leave what it posted
Along with a lot of useless files (like .class files) that are now candidates for indexing, since as I said I emptied gitignore, I believe that sample.jsp is still being ignored
source to share
You should do some inelegant solution like expanding a single file
into a directory
based on the following:
# Ignore any file in this directory except for this file and *.foo files * !/.gitignore !*.foo
If you don't want or can't add this .gitignore file, there is an inelegant solution:
# Ignore any file but *.foo under Resources. Update this if we add deeper directories Resources/* !Resources/*/ !Resources/*.foo Resources/*/* !Resources/*/*/ !Resources/*/*.foo Resources/*/*/* !Resources/*/*/*/ !Resources/*/*/*.foo Resources/*/*/*/* !Resources/*/*/*/*/ !Resources/*/*/*/*.foo
source to share