How to preserve all ignored files in git clean -fd?
What I want is to delete all unrevisioned files in a git repo while excluding all ignored files (i.e. DON’T delete gitignored files). What could I do?
- git clean -d -f removes directories containing files which are ignored. Can I keep the ignored files and still run git clean -d
- Git: need to recursively 'git rm' the contents of all bin and obj folders
- git clean: What does “Would not remove” mean?
- Difference between git reset --hard and git clean
- Why does git clean -dX not remove my ignored directory?
- git clean directories in untracked files
One Solution collect form web for “How to preserve all ignored files in git clean -fd?”
Git normally don’t clean ignored files unless you specify the
-x flag, but strangely it cleans out when configured as you did (
As @VonC commented it out, you should change your
.gitignore to ignore the directory (
data/) rather than what’s in it (
It’s a subtle difference, but it matters to git.