How do you delete untracked local files from your current working tree?
OK, deleting unwanted untracked files and folders are easy using git
in command line, just do it like this:
git clean -fd
Double check before doing it as it will delete the files and folders without making any history...
Also in this case, -f
stands for force and -d
stands for directory...
So, if you want to delete files only, you can use -f
only:
git clean -f
If you want to delete(directories) and files, you can delete only untracked directories and files like this:
git clean -fd
Also, you can use -x
flag for including the files which are ignored by git. This would be helpful if you want to delete everything.
And adding -i
flag, makes git asking you for permission for deleting files one by one on the go.
If you not sure and want to check things first, add -n
flag.
Use -q
if you don't want to see any report after successful deletion.
I also create the image below to make it more memorable, especially I have seen many people confuse -f
for cleaning folder sometimes or mix it up somehow!