How do I add an empty directory (that contains no files) to a Git repository?
Another way to make a directory stay (almost) empty (in the repository) is to create a
.gitignore file inside that directory that contains these four lines:
# Ignore everything in this directory * # Except this file !.gitignore
Then you don't have to get the order right the way that you have to do in m104's solution.
This also gives the benefit that files in that directory won't show up as "untracked" when you do a git status.
Making @GreenAsJade's comment persistent:
I think it's worth noting that this solution does precisely what the question asked for, but is not perhaps what many people looking at this question will have been looking for. This solution guarantees that the directory remains empty. It says "I truly never want files checked in here". As opposed to "I don't have any files to check in here, yet, but I need the directory here, files may be coming later".