Q . How do I remove local (untracked) files from my current Git branch?

Smit Shah. asked, Jun 27 ' 2016

How to delete local untracked files ?

  • git
  • git-delete

1 Answers

Show what will be deleted with the -n option:

git clean -f -n

Then - beware: this will delete files - run:

git clean -f

If you want to also remove directories, run git clean -f -d or git clean -fd

If you just want to remove ignored files, run git clean -f -X or git clean -fX

If you want to remove ignored as well as non-ignored files, run git clean -f -x or git clean -fx

Note the case difference on the X for the two latter commands.

If clean.requireForce is set to "true" (the default) in your configuration, then unless you specify -f nothing will actually happen.

See the git-clean docs for more information.

Leave a Ansewer