git-clean
Remove files not tracked by Git from the working tree. tldr-pages
On several platforms
Several platforms
Interactively delete untracked files
git clean --interactiveIdentifySimulate the cleanup, showing which files would be deleted
git clean --dry-runIdentifyImmediately force deletion of all untracked files
git clean --forceIdentifyDelete untracked directories
git clean --force -dIdentifyDelete only untracked files matching specific paths or glob patterns
git clean --force -- path/to/directory '*.ext'IdentifyDelete untracked files except those matching the given patterns
git clean --force --exclude '*.ext' --exclude path/to/directory/IdentifyDelete untracked files and excluded files (those listed in .gitignore and .git/info/exclude)
git clean --force -xIdentify