So you’ve got a bunch of untracked files and folders in your git repo and you don’t want to delete them all manually one-by-one. How do you use the power of git to do this for you?

git clean will remove all untracked files for you.

There are several variants:

Perform a dry run to display which files will be deleted:

git clean -dn

Once you are satisfied with the output then run:

git clean -df

This will remove all files and directories that are not tracked.

If you would like to perform an interactive removal of files and directories then use:

git clean -di