Sometimes we want to clean out our Git workspace and remove any file which is untracked. A hard reset usually does the job for modified files as shown below:
git reset --hard
But hard reset doesn’t fit in case of untracked files. The following command will do the job:
git clean -d -fx ""
-x means ignored files are also removed as well as files unknown to git.
-d means remove untracked directories in addition to untracked files.
-f is required to force it to run.
Reference:
https://www.kernel.org/pub/software/scm/git/docs/git-clean.html