How to remove local (untracked) files from the current Git working tree
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
You must login to ask question.
Be careful while running `git clean` command.
Always use
-n
before running the actual command as it will show you what files would get removed.By default,
git clean
will only remove untracked files that are not ignored. Any file that matches a pattern in your .gitignore or other ignore files will not be removed. If you want to remove those files too, you can add a-x
to the clean command.There is also interactive mode available
-i
with the clean commandAlternatively:
If you are not 100% sure that deleting your uncommitted work is safe, you could use stashing instead
It will also clear your directory but give you flexibility to retrieve the files at any point in time using stash with apply or pop. Then if you are fine with removing your stashed files you could run: