Back to lessons
Git Clean & Removing Files
Remove untracked files with git clean, track file deletions with git rm, and master .gitignore patterns.
Step 1 of 617%
Git clean removes untracked files from your working directory. Unlike git rm, which removes tracked files, git clean targets files that Git isn't tracking — build artifacts, logs, and temporary files.
Untracked files accumulate naturally during development: compiled binaries, dependency caches, editor swap files, and debug logs. While .gitignore prevents them from being staged, they still clutter your working directory and can cause confusion. git clean is the tool for sweeping these away, but it's inherently destructive because the files aren't tracked. Always use the --dry-run or -n flag first to preview what would be removed before committing to the operation.
1 / 6