Git · History and recovery

git clean

Removes untracked files and directories. Preview with -n first.

Syntax
git clean -fd

Example

Example
git clean -n
git clean -fd

More in this group

git reflog git reset --hard git reset --mixed git reset --soft git restore git revert git stash git stash apply vs pop

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course