How can I add an empty directory (that contains no files) to a Git repository?
If you want to add a folder that will house a lot of transient data in multiple semantic directories, then one approach is to add something like this to your root .gitignore...
/app/data/**/*.*
!/app/data/**/*.md
Then you can commit descriptive README.md files (or blank files, doesn't matter, as long as you can target them uniquely like with the *.md
in this case) in each directory to ensure that the directories all remain part of the repo but the files (with extensions) are kept ignored. LIMITATION: .
's are not allowed in the directory names!
You can fill up all of these directories with xml/images files or whatever and add more directories under /app/data/
over time as the storage needs for your app develop (with the README.md files serving to burn in a description of what each storage directory is for exactly).
There is no need to further alter your .gitignore
or decentralise by creating a new .gitignore
for each new directory. Probably not the smartest solution but is terse gitignore-wise and always works for me. Nice and simple! ;)