git clean

The commands to clean your git repo from untracked files. A clean repo is just nicer to work with, and you can see the status much better.

git clean -f        # delete untracked files
git clean -f -d     # delete untracked directories

git clean -i        # interactive

If unsure, use the interactive mode. It will ask you what to do.

Also exists:

git clean -n # dry run
git clean -f -x # remove untracked .gitignore files

Leave a Reply