Command Reference

git clean Tutorial

Explains how git clean removes untracked files and directories, and why dry-run and force flags are essential here.

The short version

git clean removes untracked files and directories.

Why it is risky

Those files are usually not part of Git history, which means accidental deletion is harder to recover from.

Safe pattern

git clean -n
git clean -f
git clean -fd

Always preview first with -n.