Git: How to delete all untracked files?

If you have it in ignore, use git clean -xf. You can do git clean -df but that will also remove un-tracked directories. Use -n for a dry-run.

See cleaning up un-tracked


git clean -f

User interactive approach:

git clean -i -fd

Remove .classpath [y/N]? N
Remove .gitignore [y/N]? N
Remove .project [y/N]? N
Remove .settings/ [y/N]? N
Remove src/com/amazon/arsdumpgenerator/inspector/ [y/N]? y
Remove src/com/amazon/arsdumpgenerator/manifest/ [y/N]? y
Remove src/com/amazon/arsdumpgenerator/s3/ [y/N]? y
Remove tst/com/amazon/arsdumpgenerator/manifest/ [y/N]? y
Remove tst/com/amazon/arsdumpgenerator/s3/ [y/N]? y

-i for interactive
-f for file
-d for directory

Note: Add -n or --dry-run to just check what it will do.

Tags:

Git