I want to check in a blank folder to my Git repository. Effectively, I need to ignore all of the files and folders within the folder, but not the folder itself. How can I do this? What should I put in my .gitignore file?
For those wondering why I would want to do this, I have an "upload" directory in my repository. I want to commit the blank directory, but without all the contents.
You can’t commit empty folders in git. If you want it to show up, you need to put something in it, even just an empty file.
For example, add an empty file called
.gitkeepto the folder you want to keep, then in your.gitignorefile write:Commit your
.gitignoreand.gitkeepfiles and this should resolve your issue.