Reputation: 155
Start with an empty directory.
git init
mkdir dir
touch dir/file1
git add .
git commit -m "message"
git rm dir/file1
ls
shows that nothing is left. But I'm expecting dir
, which is the result when /bin/rm
is used instead of git rm
. What happened?
Upvotes: 1
Views: 33
Reputation: 2471
Because git monitor contents only, and contents can only reside in files.
So empty directory cannot be monitor by git, hence it's deleted.
To keep a directory, one usually create a dummy file it in. Usually the file is named .gitkeep
or .gitignore
. You can leave the file empty.
Upvotes: 1