Skip to Content
Linux in a Nutshell, 6th Edition
book

Linux in a Nutshell, 6th Edition

by Ellen Siever, Stephen Figgins, Robert Love, Arnold Robbins
September 2009
Beginner
942 pages
85h 34m
English
O'Reilly Media, Inc.
Content preview from Linux in a Nutshell, 6th Edition

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
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Unix in a Nutshell, 4th Edition

Unix in a Nutshell, 4th Edition

Arnold Robbins
Linux Under the Hood

Linux Under the Hood

Sander van Vugt
Linux Kernel in a Nutshell

Linux Kernel in a Nutshell

Greg Kroah-Hartman

Publisher Resources

ISBN: 9780596806088Errata Page