1GIT-CLEAN(1)                      Git Manual                      GIT-CLEAN(1)
2
3
4

NAME

6       git-clean - Remove untracked files from the working tree
7

SYNOPSIS

9       git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] <path>...
10
11

DESCRIPTION

13       Cleans the working tree by recursively removing files that are not
14       under version control, starting from the current directory.
15
16       Normally, only files unknown to Git are removed, but if the -x option
17       is specified, ignored files are also removed. This can, for example, be
18       useful to remove all build products.
19
20       If any optional <path>... arguments are given, only those paths are
21       affected.
22

OPTIONS

24       -d
25           Remove untracked directories in addition to untracked files. If an
26           untracked directory is managed by a different Git repository, it is
27           not removed by default. Use -f option twice if you really want to
28           remove such a directory.
29
30       -f, --force
31           If the Git configuration variable clean.requireForce is not set to
32           false, git clean will refuse to delete files or directories unless
33           given -f, -n or -i. Git will refuse to delete directories with .git
34           sub directory or file unless a second -f is given.
35
36       -i, --interactive
37           Show what would be done and clean files interactively. See
38           “Interactive mode” for details.
39
40       -n, --dry-run
41           Don’t actually remove anything, just show what would be done.
42
43       -q, --quiet
44           Be quiet, only report errors, but not the files that are
45           successfully removed.
46
47       -e <pattern>, --exclude=<pattern>
48           In addition to those found in .gitignore (per directory) and
49           $GIT_DIR/info/exclude, also consider these patterns to be in the
50           set of the ignore rules in effect.
51
52       -x
53           Don’t use the standard ignore rules read from .gitignore (per
54           directory) and $GIT_DIR/info/exclude, but do still use the ignore
55           rules given with -e options. This allows removing all untracked
56           files, including build products. This can be used (possibly in
57           conjunction with git reset) to create a pristine working directory
58           to test a clean build.
59
60       -X
61           Remove only files ignored by Git. This may be useful to rebuild
62           everything from scratch, but keep manually created files.
63

INTERACTIVE MODE

65       When the command enters the interactive mode, it shows the files and
66       directories to be cleaned, and goes into its interactive command loop.
67
68       The command loop shows the list of subcommands available, and gives a
69       prompt "What now> ". In general, when the prompt ends with a single >,
70       you can pick only one of the choices given and type return, like this:
71
72               *** Commands ***
73                   1: clean                2: filter by pattern    3: select by numbers
74                   4: ask each             5: quit                 6: help
75               What now> 1
76
77
78       You also could say c or clean above as long as the choice is unique.
79
80       The main command loop has 6 subcommands.
81
82       clean
83           Start cleaning files and directories, and then quit.
84
85       filter by pattern
86           This shows the files and directories to be deleted and issues an
87           "Input ignore patterns>>" prompt. You can input space-separated
88           patterns to exclude files and directories from deletion. E.g. "*.c
89           *.h" will excludes files end with ".c" and ".h" from deletion. When
90           you are satisfied with the filtered result, press ENTER (empty)
91           back to the main menu.
92
93       select by numbers
94           This shows the files and directories to be deleted and issues an
95           "Select items to delete>>" prompt. When the prompt ends with double
96           >> like this, you can make more than one selection, concatenated
97           with whitespace or comma. Also you can say ranges. E.g. "2-5 7,9"
98           to choose 2,3,4,5,7,9 from the list. If the second number in a
99           range is omitted, all remaining items are selected. E.g. "7-" to
100           choose 7,8,9 from the list. You can say * to choose everything.
101           Also when you are satisfied with the filtered result, press ENTER
102           (empty) back to the main menu.
103
104       ask each
105           This will start to clean, and you must confirm one by one in order
106           to delete items. Please note that this action is not as efficient
107           as the above two actions.
108
109       quit
110           This lets you quit without do cleaning.
111
112       help
113           Show brief usage of interactive git-clean.
114

SEE ALSO

116       gitignore(5)
117

GIT

119       Part of the git(1) suite
120
121
122
123Git 2.18.1                        05/14/2019                      GIT-CLEAN(1)
Impressum