1

When I run git status git doesn't show the empty directory.
My remote repository is in github.
Can't I add and push empty directory?

4

The usual way to force adding an empty directory in systems that ignores empty directories is to add a hidden file in each such directory:

$ touch directoryname/.empty_dir
$ git add directoryname/.empty_dir
$ git push

With git, you may choose to use .gitignore in place of .empty_dir above (really, any name will do, and the only reason to use a hidden filename is to avoid seeing it when you list the directory's contents with ls).

2

You are not supposed to. But you can always add an empty readme.md or .gitignore to be able to do so.

See https://git.wiki.kernel.org/index.php/GitFaq#Can_I_add_empty_directories.3F.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.