Preview and Clean Untracked Files
List or delete untracked and ignored files in a working tree.
Run git clean -nd to preview what would be removed before committing to a clean.
01Command
Command
$ git clean -nd02What it does
Build scripts leave generated files that git ignores; git clean removes them without touching tracked files. The -n dry run and -X flag make it safe to preview exactly what will go, which is faster and more precise than hunting leftovers in a file manager.
03Risk
!Warning: Without -n, git clean -fd permanently deletes untracked files and cannot be undone by git.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- git-clean documentationEvidence: Documents git clean, including the -n dry run and -X ignored-only options.
Last verified: 2026-10-13 · Category: Developer
06Related solutions
Find files larger than 500 MB on Mac
List the biggest files in your home folder that are eating disk space.
Show file extensions for all files on Mac
Make Finder display .pdf, .docx, .png and every other extension at all times.
Find Which Process Has a File or Volume Open with lsof
List every open file descriptor — files, directories, and network sockets — per process.