Is there a way to remove all ignored files from a git repo?
This question already has an answer here:
git clean -dfX
git-clean - Remove untracked files from the working tree
-d
for removing directories
-f
remove forcefully
-n
Don't actually remove anything, just show what would be done.
-X
Remove only files ignored by Git. This may be useful to rebuild everything from scratch, but keep manually created files.
There is a single command solution:
git ls-files --ignored --exclude-standard | sed 's/.*/"&"/' | xargs git rm -r --cached
What it does is:
上一篇: 撤消更改