π€ Situation
The repository is like this. The notes directory is empty. How can I keep the empty directory?
$ tree
.
βββ Gemfile
βββ Gemfile.lock
βββ README.md
βββ deleted.enex
βββ notes # <- The empty directory
βββ parse.rb
βββ parse_to_notable.rb
1 directory, 6 files
π Solution
put an empty file at the directory. .gitkeep
is popularly used.
$ touch notes/.gitkeep
$ ls -A notes/
.gitkeep
Top comments (5)
Any file will work, because any file will make the folder not empty: I believe it's better practice to add a
README.md
file in the folder explaining the purpose of the folder.Otherwise future developers might find a folder sometimes with not an intuitive name and wonder what it's for: it might even no longer be used, but with not explanation of its purpose a developer would need to dig into the code to understand that.
I think
.keep
works too ;)Thank you, it works too!
It's probably worth noting that any file name would work. .gitkeep is just a popular choice for this placeholder file.
Thank you, my understanding was wrong. I've rewritten it.