Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Git for version control. Now I want to delete on my local machine all files in the repository that are not tracked.

I can use

git status

to list these files, but how can I delete all of them?

share|improve this question
Cant you just check out all the files to a different place one your machine and then delete the old version? – Nifle Sep 14 '11 at 13:59
For sure I can, but isn't there a simpler way? – RoflcoptrException Sep 14 '11 at 14:01
up vote 29 down vote accepted

If you have it in ignore, use git clean -xf. You can do git clean -df but that will also remove un-tracked directories. Use -n for a dry-run.

See cleaning up un-tracked

share|improve this answer
-x ignores the ignores.. – UpAndAdam Apr 10 '14 at 19:01
-xf will delete and the ignored files and this is probably NOT what you want. Use -nf and proceed with care. See:… – Mr_and_Mrs_D Jul 9 '14 at 21:13
Remember, this may remove your environment/IDE folders (e.g. .vagrant or .idea (phpstorm)) – timhc22 Nov 21 '14 at 12:12
git clean -f
share|improve this answer
It might make sense to add the meaning of that command to make this answer self-contained. – N.N. Sep 14 '11 at 18:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.