git clean Delete untracked files from the working folder
Removes files Git does not track, such as build output or stray new files. It is permanent, so do a dry run first.
Synopsis
git clean [OPTION]... [PATH]...
Common options
| Option or form | What it does |
|---|---|
-n, --dry-run | Show what would be deleted without deleting |
-f, --force | Actually delete. Required by default |
-d | Include untracked folders |
-x | Also remove files ignored by .gitignore |
-i | Choose interactively |
Examples
git clean -n
Would remove notes.txt
git clean -f
git clean -fd
git clean -fdx
git clean -i
Notes
- Files removed by clean are not in the Trash and are not in Git, so they cannot be recovered.
- -x also deletes ignored files like .env and node_modules.
- Always run with -n first and read the list.
See also
Last reviewed 2026-10-09.