Skip to content
Search

Git:Clean

lastmod 2015-08-07created 2015-08-072 edits

Notes on how to use the git-clean command.

Remove Untracked files

Removes only untracked files.

git clean -f

Dry run

Does not remove files; only prints the files that would be removed.

git clean -n
## or
git clean --dry-run

Remove only files ignored by git

Removes only what is defined in the gitignore file.

git clean -X

This works differently from the lowercase (-x). Mind the case.

x option

The -x option ignores the rules in $GIT_DIR/info/exclude and the .gitignore rules. However, exclude patterns given with -e can still be used.

It seems to delete untracked files as well as other files. If unsure, it is recommended to test with the Dry-run option first.