There is no way to commit an empty directory to a Git repository, you have to put a file in the directory to be able to commit it to your repo. Here is an explanation from the Git FAQ:
Currently the design of the Git index (staging area) only permits files to be listed, and nobody competent enough to make the change to allow empty directories has cared enough about this situation to remedy it.
Directories are added automatically when adding files inside them. That is, directories never have to be added to the repository, and are not tracked on their own.
So now we know that we have to put a file in the directory. But what file should it be?
If we are forced to put in a file we should make the best of it. Use a file that has at least some use, or could have a use in the future.
Some say, that the best idea is to use a
README file, and inside it, describe why did you leave this directory empty. This could be a good idea, but sometimes the reason for the directory being there is obvious (e.g. Controllers), you just don’t have any files in it, because you did not get to that point in the development.
Git uses the
.gitignore file to determine which files to exclude from tracking in the repository. Putting in an empty one leaves the possibility of adding exclusion rules later.
In some people’s opinion the filename should be descriptive about the purpose of it. They use a file named
.gitkeep, that just means “Keep this folder in revision control, although it’s empty”.