Last Updated: February 25, 2016
·
1.011K
· kisom

Cleaning a git repository

Sometimes, your repo acquires a lot of unnecessary clutter (test files, autoconf-generated files); a way to automatically remove all these files is with with git clean. To remove all files in the working directory that aren't under source control:

git clean -fxd

The -d flag tells git clean to work recursively; -x tells it to remove files being ignored, and -f is required if the git configuration variable clean.requireForce is enabled. Instead of -f, the -n option performs a dry run, only listing the files that would be removed.