summaryrefslogtreecommitdiff
path: root/devdocs/git/git-clean.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/git/git-clean.html
new repository
Diffstat (limited to 'devdocs/git/git-clean.html')
-rw-r--r--devdocs/git/git-clean.html9
1 files changed, 9 insertions, 0 deletions
diff --git a/devdocs/git/git-clean.html b/devdocs/git/git-clean.html
new file mode 100644
index 00000000..a29cb971
--- /dev/null
+++ b/devdocs/git/git-clean.html
@@ -0,0 +1,9 @@
+<h1>git-clean</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-clean - Remove untracked files from the working tree</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git clean [-d] [-f] [-i] [-n] [-q] [-e &lt;pattern&gt;] [-x | -X] [--] [&lt;pathspec&gt;…​]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Cleans the working tree by recursively removing files that are not under version control, starting from the current directory.</p> <p>Normally, only files unknown to Git are removed, but if the <code>-x</code> option is specified, ignored files are also removed. This can, for example, be useful to remove all build products.</p> <p>If any optional <code>&lt;pathspec&gt;...</code> arguments are given, only those paths that match the pathspec are affected.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-clean.txt--d"> -d </dt> <dd> <p>Normally, when no &lt;pathspec&gt; is specified, git clean will not recurse into untracked directories to avoid removing too much. Specify -d to have it recurse into such directories as well. If a &lt;pathspec&gt; is specified, -d is irrelevant; all untracked files matching the specified paths (with exceptions for nested git directories mentioned under <code>--force</code>) will be removed.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-clean.txt---force"> --force </dt> <dd> <p>If the Git configuration variable clean.requireForce is not set to false, <code>git clean</code> will refuse to delete files or directories unless given -f or -i. Git will refuse to modify untracked nested git repositories (directories with a .git subdirectory) unless a second -f is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-clean.txt---interactive"> --interactive </dt> <dd> <p>Show what would be done and clean files interactively. See “Interactive mode” for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-clean.txt---dry-run"> --dry-run </dt> <dd> <p>Don’t actually remove anything, just show what would be done.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-clean.txt---quiet"> --quiet </dt> <dd> <p>Be quiet, only report errors, but not the files that are successfully removed.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt--eltpatterngt"> -e &lt;pattern&gt; </dt> <dt class="hdlist1" id="Documentation/git-clean.txt---excludeltpatterngt"> --exclude=&lt;pattern&gt; </dt> <dd> <p>Use the given exclude pattern in addition to the standard ignore rules (see <a href="gitignore">gitignore[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt--x"> -x </dt> <dd> <p>Don’t use the standard ignore rules (see <a href="gitignore">gitignore[5]</a>), but still use the ignore rules given with <code>-e</code> options from the command line. This allows removing all untracked files, including build products. This can be used (possibly in conjunction with <code>git restore</code> or <code>git reset</code>) to create a pristine working directory to test a clean build.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt--X"> -X </dt> <dd> <p>Remove only files ignored by Git. This may be useful to rebuild everything from scratch, but keep manually created files.</p> </dd> </dl> </div> </div> <h2 id="_interactive_mode">Interactive mode</h2> <div class="sectionbody"> <p>When the command enters the interactive mode, it shows the files and directories to be cleaned, and goes into its interactive command loop.</p> <p>The command loop shows the list of subcommands available, and gives a prompt "What now&gt; ". In general, when the prompt ends with a single <code>&gt;</code>, you can pick only one of the choices given and type return, like this:</p> <div class="listingblock"> <div class="content"> <pre> *** Commands ***
+ 1: clean 2: filter by pattern 3: select by numbers
+ 4: ask each 5: quit 6: help
+ What now&gt; 1</pre> </div> </div> <p>You also could say <code>c</code> or <code>clean</code> above as long as the choice is unique.</p> <p>The main command loop has 6 subcommands.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-clean.txt-clean"> clean </dt> <dd> <p>Start cleaning files and directories, and then quit.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt-filterbypattern"> filter by pattern </dt> <dd> <p>This shows the files and directories to be deleted and issues an "Input ignore patterns&gt;&gt;" prompt. You can input space-separated patterns to exclude files and directories from deletion. E.g. "*.c *.h" will exclude files ending with ".c" and ".h" from deletion. When you are satisfied with the filtered result, press ENTER (empty) back to the main menu.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt-selectbynumbers"> select by numbers </dt> <dd> <p>This shows the files and directories to be deleted and issues an "Select items to delete&gt;&gt;" prompt. When the prompt ends with double <code>&gt;&gt;</code> like this, you can make more than one selection, concatenated with whitespace or comma. Also you can say ranges. E.g. "2-5 7,9" to choose 2,3,4,5,7,9 from the list. If the second number in a range is omitted, all remaining items are selected. E.g. "7-" to choose 7,8,9 from the list. You can say <code>*</code> to choose everything. Also when you are satisfied with the filtered result, press ENTER (empty) back to the main menu.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt-askeach"> ask each </dt> <dd> <p>This will start to clean, and you must confirm one by one in order to delete items. Please note that this action is not as efficient as the above two actions.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt-quit"> quit </dt> <dd> <p>This lets you quit without doing any cleaning.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt-help"> help </dt> <dd> <p>Show brief usage of interactive git-clean.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-clean.txt-cleanrequireForce"> clean.requireForce </dt> <dd> <p>A boolean to make git-clean do nothing unless given -f, -i, or -n. Defaults to true.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gitignore">gitignore[5]</a></p> </div><div class="_attribution">
+ <p class="_attribution-p">
+ &copy; 2012&ndash;2024 Scott Chacon and others<br>Licensed under the MIT License.<br>
+ <a href="https://git-scm.com/docs/git-clean" class="_attribution-link">https://git-scm.com/docs/git-clean</a>
+ </p>
+</div>