{
    "content": [
        {
            "type": "text",
            "text": "# git-clean (man)\n\n## NAME\n\ngit-clean - Remove untracked files from the working tree\n\n## SYNOPSIS\n\ngit clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] <path>...\n\n## DESCRIPTION\n\nCleans the working tree by recursively removing files that are not under version control,\nstarting from the current directory.\n\n## TLDR\n\n> Remove files not tracked by Git from the working tree.\n\n- Interactively delete untracked files:\n  `git clean {{-i|--interactive}}`\n- Show which files would be deleted without actually deleting them:\n  `git clean {{-n|--dry-run}}`\n- Immediately force deletion of all untracked files:\n  `git clean {{-f|--force}}`\n- Delete untracked [d]irectories:\n  `git clean {{-f|--force}} -d`\n- Delete only untracked files matching specific paths or glob patterns:\n  `git clean {{-f|--force}} -- {{path/to/directory}} '{{*.ext}}'`\n- Delete untracked files except those matching the given patterns:\n  `git clean {{-f|--force}} {{-e|--exclude}} '{{*.ext}}' {{-e|--exclude}} {{path/to/directory}}/`\n- Delete untracked files and e[x]cluded files (those listed in `.gitignore` and `.git/info/exclude`):\n  `git clean {{-f|--force}} -x`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS** (7 subsections)\n- **INTERACTIVE MODE**\n- **SEE ALSO**\n- **GIT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "git-clean",
        "section": "",
        "mode": "man",
        "summary": "git-clean - Remove untracked files from the working tree",
        "synopsis": "git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] <path>...",
        "tldr_summary": "Remove files not tracked by Git from the working tree.",
        "tldr_examples": [
            {
                "description": "Interactively delete untracked files",
                "command": "git clean {{-i|--interactive}}"
            },
            {
                "description": "Show which files would be deleted without actually deleting them",
                "command": "git clean {{-n|--dry-run}}"
            },
            {
                "description": "Immediately force deletion of all untracked files",
                "command": "git clean {{-f|--force}}"
            },
            {
                "description": "Delete untracked [d]irectories",
                "command": "git clean {{-f|--force}} -d"
            },
            {
                "description": "Delete only untracked files matching specific paths or glob patterns",
                "command": "git clean {{-f|--force}} -- {{path/to/directory}} '{{*.ext}}'"
            },
            {
                "description": "Delete untracked files except those matching the given patterns",
                "command": "git clean {{-f|--force}} {{-e|--exclude}} '{{*.ext}}' {{-e|--exclude}} {{path/to/directory}}/"
            },
            {
                "description": "Delete untracked files and e[x]cluded files (those listed in `.gitignore` and `.git/info/exclude`)",
                "command": "git clean {{-f|--force}} -x"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "-d",
                "long": null,
                "arg": null,
                "description": "Normally, when no <path> 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 any paths are specified, -d is irrelevant; all untracked files matching the specified paths (with exceptions for nested git directories mentioned under --force) will be removed."
            },
            {
                "flag": "-f",
                "long": "--force",
                "arg": null,
                "description": "If the Git configuration variable clean.requireForce is not set to false, git clean 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."
            },
            {
                "flag": "-i",
                "long": "--interactive",
                "arg": null,
                "description": "Show what would be done and clean files interactively. See “Interactive mode” for details."
            },
            {
                "flag": "-n",
                "long": "--dry-run",
                "arg": null,
                "description": "Don’t actually remove anything, just show what would be done."
            },
            {
                "flag": "-q",
                "long": "--quiet",
                "arg": null,
                "description": "Be quiet, only report errors, but not the files that are successfully removed. -e <pattern>, --exclude=<pattern> Use the given exclude pattern in addition to the standard ignore rules (see gitignore(5))."
            },
            {
                "flag": "-x",
                "long": null,
                "arg": null,
                "description": "Don’t use the standard ignore rules (see gitignore(5)), but still use the ignore rules given with -e options from the command line. This allows removing all untracked files, including build products. This can be used (possibly in conjunction with git restore or git reset) to create a pristine working directory to test a clean build."
            },
            {
                "flag": "-X",
                "long": null,
                "arg": null,
                "description": "Remove only files ignored by Git. This may be useful to rebuild everything from scratch, but keep manually created files."
            }
        ],
        "examples": [],
        "see_also": [
            {
                "name": "gitignore",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/gitignore/5/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "-d",
                        "lines": 6,
                        "flag": "-d"
                    },
                    {
                        "name": "-f, --force",
                        "lines": 5,
                        "flag": "-f",
                        "long": "--force"
                    },
                    {
                        "name": "-i, --interactive",
                        "lines": 3,
                        "flag": "-i",
                        "long": "--interactive"
                    },
                    {
                        "name": "-n, --dry-run",
                        "lines": 2,
                        "flag": "-n",
                        "long": "--dry-run"
                    },
                    {
                        "name": "-q, --quiet",
                        "lines": 6,
                        "flag": "-q",
                        "long": "--quiet"
                    },
                    {
                        "name": "-x",
                        "lines": 5,
                        "flag": "-x"
                    },
                    {
                        "name": "-X",
                        "lines": 3,
                        "flag": "-X"
                    }
                ]
            },
            {
                "name": "INTERACTIVE MODE",
                "lines": 46,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "GIT",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "git-clean - Remove untracked files from the working tree\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] <path>...\n\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Cleans the working tree by recursively removing files that are not under version control,\nstarting from the current directory.\n\nNormally, only files unknown to Git are removed, but if the -x option is specified, ignored\nfiles are also removed. This can, for example, be useful to remove all build products.\n\nIf any optional <path>... arguments are given, only those paths are affected.\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "",
                "subsections": [
                    {
                        "name": "-d",
                        "content": "Normally, when no <path> is specified, git clean will not recurse into untracked\ndirectories to avoid removing too much. Specify -d to have it recurse into such\ndirectories as well. If any paths are specified, -d is irrelevant; all untracked files\nmatching the specified paths (with exceptions for nested git directories mentioned under\n--force) will be removed.\n",
                        "flag": "-d"
                    },
                    {
                        "name": "-f, --force",
                        "content": "If the Git configuration variable clean.requireForce is not set to false, git clean will\nrefuse to delete files or directories unless given -f or -i. Git will refuse to modify\nuntracked nested git repositories (directories with a .git subdirectory) unless a second\n-f is given.\n",
                        "flag": "-f",
                        "long": "--force"
                    },
                    {
                        "name": "-i, --interactive",
                        "content": "Show what would be done and clean files interactively. See “Interactive mode” for\ndetails.\n",
                        "flag": "-i",
                        "long": "--interactive"
                    },
                    {
                        "name": "-n, --dry-run",
                        "content": "Don’t actually remove anything, just show what would be done.\n",
                        "flag": "-n",
                        "long": "--dry-run"
                    },
                    {
                        "name": "-q, --quiet",
                        "content": "Be quiet, only report errors, but not the files that are successfully removed.\n\n-e <pattern>, --exclude=<pattern>\nUse the given exclude pattern in addition to the standard ignore rules (see\ngitignore(5)).\n",
                        "flag": "-q",
                        "long": "--quiet"
                    },
                    {
                        "name": "-x",
                        "content": "Don’t use the standard ignore rules (see gitignore(5)), but still use the ignore rules\ngiven with -e options from the command line. This allows removing all untracked files,\nincluding build products. This can be used (possibly in conjunction with git restore or\ngit reset) to create a pristine working directory to test a clean build.\n",
                        "flag": "-x"
                    },
                    {
                        "name": "-X",
                        "content": "Remove only files ignored by Git. This may be useful to rebuild everything from scratch,\nbut keep manually created files.\n",
                        "flag": "-X"
                    }
                ]
            },
            "INTERACTIVE MODE": {
                "content": "When the command enters the interactive mode, it shows the files and directories to be\ncleaned, and goes into its interactive command loop.\n\nThe command loop shows the list of subcommands available, and gives a prompt \"What now> \". In\ngeneral, when the prompt ends with a single >, you can pick only one of the choices given and\ntype return, like this:\n\n* Commands *\n1: clean                2: filter by pattern    3: select by numbers\n4: ask each             5: quit                 6: help\nWhat now> 1\n\n\nYou also could say c or clean above as long as the choice is unique.\n\nThe main command loop has 6 subcommands.\n\nclean\nStart cleaning files and directories, and then quit.\n\nfilter by pattern\nThis shows the files and directories to be deleted and issues an \"Input ignore\npatterns>>\" prompt. You can input space-separated patterns to exclude files and\ndirectories from deletion. E.g. \"*.c *.h\" will excludes files end with \".c\" and \".h\" from\ndeletion. When you are satisfied with the filtered result, press ENTER (empty) back to\nthe main menu.\n\nselect by numbers\nThis shows the files and directories to be deleted and issues an \"Select items to\ndelete>>\" prompt. When the prompt ends with double >> like this, you can make more than\none selection, concatenated with whitespace or comma. Also you can say ranges. E.g. \"2-5\n7,9\" to choose 2,3,4,5,7,9 from the list. If the second number in a range is omitted, all\nremaining items are selected. E.g. \"7-\" to choose 7,8,9 from the list. You can say * to\nchoose everything. Also when you are satisfied with the filtered result, press ENTER\n(empty) back to the main menu.\n\nask each\nThis will start to clean, and you must confirm one by one in order to delete items.\nPlease note that this action is not as efficient as the above two actions.\n\nquit\nThis lets you quit without do cleaning.\n\nhelp\nShow brief usage of interactive git-clean.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "gitignore(5)\n",
                "subsections": []
            },
            "GIT": {
                "content": "Part of the git(1) suite\n\n\n\nGit 2.34.1                                   02/26/2026                                 GIT-CLEAN(1)",
                "subsections": []
            }
        }
    }
}