[git] Keep empty directory by .gitkeep

twitter logo github logo Updated on ・1 min read

πŸ€” 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/

like this

πŸ”— Parent Note

twitter logo DISCUSS (4)
markdown guide

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.

Classic DEV Post from Sep 9 '19

What I learned after applying to 100 jobs

n350071 profile image
Ruby Web Developer. Freelancer.