Remove Untracked Files With Git
When working with Git I sometimes end up with a lot of untracked local files that I want to get rid of. For example, compiling things and testing around can create more stuff than expected or a git reset origin/master
rolling back a lot of commits can leave a bunch of leftovers. To me this happens a few times a year and each time I realize that I forgot how I solved it last time. The answer is: git clean
.
git clean -n
Dry-run, show what would be deletedgit clean -f
Really delete itgit clean -d
Recurse into untracked directories
For me this usually means git clean -f -d
and I am done. For more options check out the man page.