GIT-CLEAN(1)
β¨ git-clean(1) β the girlies' guide to yeeting untracked files π
okay so bestie, welcome to git-clean(1), your new favorite manual page π she lives in the git manual family, and she is literally about to help you clean up your working tree. no cap.
πΈ NAME πΈ
git-clean β remove untracked files from the working tree π§Ήβ¨
π¦ SYNOPSIS π¦
git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] [<pathspec>...]
that's the whole vibe check right there, bestie π
π DESCRIPTION π
okay so what does she actually do? she cleans your working tree by recursively removing files that are not under version control, starting from the current directory π«Ά think of her as that friend who comes over and just... starts throwing things away. iconic. terrifying. effective.
normally, only files unknown to Git get removed β that's the default, that's the lane she stays in. but if you specify the -x option, ignored files are also removed π which is, for example, super useful to remove all build products. yes queen, wipe the whole build folder.
and if you give her any optional <pathspec>... arguments, only those paths that match the pathspec are affected π― she's not gonna touch anything outside your little target zone.
β¨ OPTIONS β¨
-dβ okay so normally, when no<pathspec>is specified,git cleanwill not recurse into untracked directories, because she's trying not to remove too much π specify-dto have her recurse into those directories as well. but listen: if a<pathspec>is specified,-dis irrelevant β all untracked files matching the specified paths (with exceptions for nested git directories mentioned under--force) will be removed. so like, it stops mattering. iykyk.-f,--forceβ the safety latch π if the Git configuration variableclean.requireForceis not set to false,git cleanwill refuse to delete files or directories unless given-f. and it gets spicier: Git will refuse to modify untracked nested git repositories (directories with a.gitsubdirectory) unless a second-fis given π³ yes, two. double force. double the commitment.-i,--interactiveβ show what would be done and clean files interactively π see "Interactive mode" for details. and good news: the configuration variableclean.requireForceis ignored here, because this mode gives its own safety protection by going interactive. she's got her own seatbelt, bestie π-n,--dry-runβ don't actually remove anything, just show what would be done π literally a look-only mode, no touching. the configuration variableclean.requireForceis ignored here too, since nothing will be deleted anyway. so you can be nosy for free π-q,--quietβ be quiet π€« only report errors, but not the files that are successfully removed. she still tells you when things go wrong tho, because communication is key.-e <pattern>,--exclude=<pattern>β use the given exclude pattern in addition to the standard ignore rules (seegitignore(5)) π§ so you're stacking your own rules on top of the usual ones.-xβ don't use the standard ignore rules (seegitignore(5)), but still use the ignore rules given with-eoptions from the command line π₯ this allows removing all untracked files, including build products. this can be used (possibly in conjunction withgit restoreorgit reset) to create a pristine working directory to test a clean build β¨ pristine. immaculate. that's the energy.-Xβ remove only files ignored by Git π this may be useful to rebuild everything from scratch, but keep manually created files. so your handcrafted little guys stay safe π«Ά
π INTERACTIVE MODE π
when the command enters the interactive mode, it shows the files and directories to be cleaned, and goes into its interactive command loop π
the command loop shows the list of subcommands available, and gives a prompt What now> . in general, when the prompt ends with a single >, you can pick only one of the choices given and type return, like this:
*** Commands ***
1: clean 2: filter by pattern 3: select by numbers
4: ask each 5: quit 6: help
What now> 1
you also could say c or clean above as long as the choice is unique π abbreviations slay, ambiguity does not.
the main command loop has 6 subcommands β here they are, one by one:
β¨ the subcommands β¨
cleanβ start cleaning files and directories, and then quit π§Ήπ¨ that's it. that's the whole thing. go off.filter by patternβ this shows the files and directories to be deleted and issues anInput ignore patterns>>prompt π you can input space-separated patterns to exclude files and directories from deletion. e.g.*.c *.hwill exclude files ending with.cand.hfrom deletion. when you are satisfied with the filtered result, press ENTER (empty) to go back to the main menu πselect by numbersβ this shows the files and directories to be deleted and issues aSelect items to delete>>prompt π’ when the prompt ends with double>>like this, you can make more than one selection, concatenated with whitespace or comma. also you can say ranges π e.g.2-5 7,9to choose2,3,4,5,7,9from the list. if the second number in a range is omitted, all remaining items are selected β e.g.7-to choose7,8,9from the list. you can say*to choose everything. also when you are satisfied with the filtered result, press ENTER (empty) back to the main menu πask eachβ 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. it's giving careful and slow, but honest work.quitβ this lets you quit without doing any cleaning π no damage, no cleanup, we simply leave.helpβ show brief usage of interactivegit-cleanπ«Ά the built-in tutorial bestie.
π CONFIGURATION π
okay so heads up: everything below this line in this section is selectively included from the git-config(1) documentation. the content is the same as what's found there π so it's a little guest appearance from another manpage.
clean.requireForceβ a boolean to makegit-cleanrefuse to delete files unless-fis given. defaults totrueβ so yeah, by default she's asking for the force flag. that's the whole personality of this config variable, and honestly? fair.
π¦ SEE ALSO π¦
gitignore(5) β go read it, it's the ignore-rules lore you need πΈ
π GIT π
part of the git(1) suite π one big happy family of tools.
and that's the page, bestie π go forth, run git clean -n first like a responsible icon, and remember: with great -f comes great responsibility πβ¨
this page brought to you by Git 2.56.0, dated 2026-09-27 β mwah, stan the git suite ππ
π¦ where this page comes from
- arch rolling: git 2.56.0-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms