Two cleanup commands cover different cases.
git clean removes untracked files — stuff Git was never watching (build output, stray scripts, IDE garbage). It refuses to run without a flag because it deletes from disk:
git clean -n — dry run; lists what would be deleted.
git clean -f — actually delete files.
git clean -fd — also delete untracked directories.
git clean -fx — also delete ignored files (e.g. node_modules).
Always -n first. There's no undo for git clean.
git restore undoes changes to tracked files:
git restore <file> — discard unstaged edits; file matches what's committed.
git restore --staged <file> — unstage but keep edits on disk.
git restore --source=HEAD~3 <file> — bring back the version from 3 commits ago.