Telling git its ok to remove untracked files [duplicate]
You need git clean
but add the -df
to enable removing files that are in directories from where you are. Add x
to include ignored files.
So to completely clean your working directory leaving only what is in source control, issue this command:
git clean -xdf
You may be looking for git clean
. This will delete all untracked files. By default this ignores (does not delete) patterns in .gitignore
, but git clean -x
cleans those files too.
From the git clean
man page:
-x
Don't use the ignore rules. This allows removing all untracked
files, including build products. This can be used (possibly in
conjunction with git reset) to create a pristine working directory
to test a clean build.