O'Reilly logo

Linux in a Nutshell, 6th Edition by Robert Love, Stephen Figgins, Ellen Siever, Arnold Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

clean

Synopsis

git clean -n|-f [-d] [-x]

Removes files from the work tree that are not in the Git index. By default, it only removes files that are not listed in .gitignore and does not remove directories. (To undo work tree changes to files that are in the index, use git checkout.)

You must provide one of -n or -f.

Options

-n (print only, do not remove)
-f (force removal of files)
-d (also remove extra directories)
-x (also remove files skipped by .gitignore)
-X (only remove files skipped by .gitignore)
-q (quiet)

Examples

To remove all extra files in the work tree so the only files remaining are ones that would be there after a fresh git clone:

$ git clean -f -d -x
Removing foo

To see what would happen if you ran the above command:

$ git clean -n -d -x
Would remove foo

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required