Git Clean

Git clean will hell you to remove all untracked files in the working directory, this post will show the basic usage.

Step 1

Review what will be deleted by using the

-n

option:

git clean -n

Step 2

Delete the files

git clean -f
  • To remove directories, run
    git clean -f -d

    or

    git clean -fd
  • To remove ignored files, run
    git clean -f -X

    or

    git clean -fX
  • To remove ignored and 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, one needs to specify

-f

otherwise nothing will actually happen.

See the

git-clean

docs for more information.

0 comments on “Git CleanAdd yours →

Leave a Reply

Your email address will not be published. Required fields are marked *