Including an empty directory in a Git repo can be useful for binary or object directories, so you don’t have to bother with
mkdir commands in the build system.
Include an empty directory in a Git repo by creating an empty file, even if the directory itself is in
.gitignore as follows.
This example assumes
bin/ contents should be ignored by Git, but the empty directory
bin/ should exist in the Git repo.
- add to
- make an empty file in
bin/and add it to Git:
touch bin/.ignore git add -f bin/.ignore
git commitas usual.