3 # Copyright (c) 2005-2006 Pavel Roskin
8 git-clean [options] <paths>...
10 Clean untracked files from the working directory
12 When optional <paths>... arguments are given, the paths
13 affected are further limited to those that match them.
15 d remove directories as well
16 f override clean.requireForce and clean anyway
17 n don't remove anything, just show what would be done
18 q be quiet, only report errors
19 x remove ignored files as well
20 X remove only ignored files"
31 rm_refuse="echo Not removing"
34 disabled=$(git config --bool clean.requireForce)
47 rmf="echo Would remove"
48 rmrf="echo Would remove"
49 rm_refuse="echo Would not remove"
66 usage # should not happen
72 # requireForce used to default to false but now it defaults to true.
73 # IOW, lack of explicit "clean.requireForce = false" is taken as
74 # "clean.requireForce = true".
77 die "clean.requireForce not set and -n or -f not given; refusing to clean"
80 die "clean.requireForce set and -n or -f not given; refusing to clean"
84 if [ "$ignored,$ignoredonly" = "1,1" ]; then
85 die "-x and -X cannot be set together"
88 if [ -z "$ignored" ]; then
89 excl="--exclude-per-directory=.gitignore"
90 excl_info= excludes_file=
91 if [ -f "$GIT_DIR/info/exclude" ]; then
92 excl_info="--exclude-from=$GIT_DIR/info/exclude"
94 if cfg_excl=$(git config core.excludesfile) && test -f "$cfg_excl"
96 excludes_file="--exclude-from=$cfg_excl"
98 if [ "$ignoredonly" ]; then
99 excl="$excl --ignored"
103 git ls-files --others --directory \
104 $excl ${excl_info:+"$excl_info"} ${excludes_file:+"$excludes_file"} \
106 while read -r file; do
107 if [ -d "$file" -a ! -L "$file" ]; then
108 if [ -z "$cleandir" ]; then
112 $echo1 "Removing $file"
115 $echo1 "Removing $file"