How to Remove Untracked Files in Git (git clean)
git clean deletes files that are untracked by Git — files never added or committed — from your working directory.
Published September 28, 2026
git clean deletes files that are untracked by Git — files never added or committed — from your working directory.
Key points
- git clean -n performs a dry run, listing what would be deleted without actually removing anything — always run this first
- git clean -f actually deletes the untracked files listed
- git clean -fd also removes untracked directories, and -x additionally removes files ignored by .gitignore
Example
git clean -n\ngit clean -fd