How to remove local (untracked) files from the current Git working tree?
Step 1 is to show what will be deleted by using the
git clean -n
Clean Step - beware: this will delete files:
git clean -f
- To remove directories, run
git clean -f -dor
git clean -fd
- To remove ignored files, run
git clean -f -Xor
git clean -fX
- To remove ignored and non-ignored files, run
git clean -f -xor
git clean -fx
Note the case difference on the
X for the two latter commands.
clean.requireForce is set to "true" (the default) in your configuration, one needs to specify
-f otherwise nothing will actually happen.