As the title says: Why is it not possible to store an empty directory in git?
For example, in a new repo:
$ mkdir foo
$ git add foo
$ git status
On branch master
Initial commit
nothing to commit (create/copy files and use "git add" to track)
The empty directory foo is not in the changelog.
I found this in the Git FAQ (translated):
And this answer elaborates on the .gitignore option , and secures that content:
It is also usual to use the .gitkeep file inside the directory if it is really necessary to create the directory and version it, inside the file you can briefly write why you need to keep the versioned directory even if you do not have any other file apart from .gitkeep . This is just a convention, for git this file has no special meaning.
Repositories are used to store a history of changes to .
A directory as such is not going to have a history of changes, so it doesn't make much sense for a repository to store an empty directory.
Keep in mind that repositories usually create directories only to replicate the organization of the files that are uploaded. That is, a directory only serves as a means to store files. If a directory is empty it loses its meaning within the repository.