git clean -d -f
removes directories containing files which are ignored. Can I keep the ignored files and still run git clean -d
?
Example:
dir\dir2\file1
.gitignore:
dir\dir2
git clean -d -f
removes dir
and all it's contents. I would expect it to realize that i'm ignoring dir\dir2\file1
and not delete file1
.
I've observed the same behavior and cannot find it listed in a bug. It's certainly still the behavior in
git
2.0.4.The work-around i've found it to add a dummy file in the empty directory that is contains the ignored file, so that it is no longer considered by
-d
, e.g.Being a .dotfile it's ignored from directory listing, so it's fairly unobtrusive and it does keep the directory put.