How do you delete untracked local files from your current working tree?
If you just want to delete the files listed as untracked by 'git status'
git stash save -u
git stash drop "stash@{0}"
I prefer this to 'git clean' because 'git clean' will delete files ignored by git, so your next build will have to rebuild everything and you may lose your IDE settings too.
git-clean - Remove untracked files from the working tree
Clean out git repository and all submodules recursively
The following command will clean out the current git repository and all its submodules recursively:
(git clean -d -x -f && git submodule foreach --recursive git clean -d -x -f)
This is what I always use:
git clean -fdx
For a very large project you might want to run it a couple of times.
git-clean is what you are looking for. It is used to remove untracked files from the working tree.
We can easily removed local untracked files from the current git working tree by using below git comments.
git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]
Example:
git reset --hard HEAD
Links :