Removing untracked files/directories in git

To remove untracked files/directories, use git-clean.

Running git-clean prints out what it would remove, without actually removing them.

-f flag removes the files and -d flag removes empty directories

So to remove untracked files and directories:

git clean -df

To also remove ignored files:

git clean -dfx
Written on March 9, 2016 by hasithapathiraja