Empty folders in git
There are two situations that can arise when using git and working with empty directories.
- You’d like to add an empty folder to git, which will later contain files which themselves will be added to git. This could occur if you’re creating the directory layout for a project. Solution: Just add an empty file called .keep to the directory
touch path/to/empty/dir/.keep; git add path/to/empty/dir/.keep
- You’d like to add an empty folder to git, but all files created inside of it should be ignored. This could occur if you’re creating a
logsdirectory for example. Solution: Add a .gitignore file inside the directory with the following contents