How can I add an empty directory (that contains no files) to a Git repository?
As described in other answers, Git is unable to represent empty directories in its staging area. (See the Git FAQ.) However, if, for your purposes, a directory is empty enough if it contains a .gitignore
file only, then you can create .gitignore
files in empty directories only via:
find . -type d -empty -exec touch {}/.gitignore \;