To remove all untracked files & directories, you can use these commands:
- first list what is going to be removed, and verify what will be deleted:
git clean -fdx -n - after you verified what is going to be deleted, remove the -n flag:
git clean -fdx
the flags we use here are:
- -f force, in case your git config has the clean.requireForce variable
- -x to remove both ignored & non ignored files
- -d remove untracked directories as well
- -n don’t remove anything, just list what will be deleted