Git Stash, Worktree, and Clean Cheat Sheet/Delete untracked files and directories

Remove untracked files and directories.

Section: Clean and Temporary File Management

Delete untracked files and directories

bash
bash
git clean -fd
Explanation

Common when resetting a repository after generated build artifacts and local temp directories.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Clean and Temporary File Management
Preview untracked file deletion
Dry-run a cleanup of untracked files.
OpenIn sheetbashsame section
Delete untracked files
Remove untracked files from the working tree.
OpenIn sheetbashsame section
Delete ignored files too
Remove ignored and untracked files and directories.
OpenIn sheetbashsame section
Interactive clean
Review and select files to remove interactively.
OpenIn sheetbashsame section
Create a named stash
Save tracked changes with a message.
OpenIn sheetbash1 tag match
List worktrees
Show all linked working trees for the repository.
OpenIn sheetbash1 tag match