{
    "content": [
        {
            "type": "text",
            "text": "# git-checkout-index(1) (man)\n\n**Summary:** git-checkout-index - Copy files from the index to the working tree\n\n**Synopsis:** git checkout-index [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]\n[--stage=<number>|all]\n[--temp]\n[-z] [--stdin]\n[--] [<file>...]\n\n## Flags\n\n| Flag | Long | Arg | Description |\n|------|------|-----|-------------|\n| -u | --index | — | update stat information for the checked out entries in the index file. |\n| -q | --quiet | — | be quiet if files exist or are not in the index |\n| -f | --force | — | forces overwrite of existing files |\n| -a | --all | — | checks out all files in the index. Cannot be used together with explicit filenames. |\n| -n | --no-create | — | Don’t checkout new files, only refresh files already checked out. --prefix=<string> When creating files, prepend <string |\n| — | --temp | — | Instead of copying the files to the working directory write the content to temporary files. The temporary name associati |\n| — | --stdin | — | Instead of taking list of paths from the command line, read list of paths from the standard input. Paths are separated b |\n| -z | — | — | Only meaningful with --stdin; paths are separated with NUL character instead of LF. -- Do not interpret any more argumen |\n\n## Examples\n\n- `To update and refresh only the files already checked out`\n- `$ git checkout-index -n -f -a && git update-index --ignore-missing --refresh`\n- `Using git checkout-index to \"export an entire tree\"`\n- `The prefix ability basically makes it trivial to use git checkout-index as an \"export as`\n- `tree\" function. Just read the desired tree into the index, and do:`\n- `$ git checkout-index --prefix=git-export-dir/ -a`\n- `git checkout-index will \"export\" the index into the specified directory.`\n- `The final \"/\" is important. The exported name is literally just prefixed with the`\n- `specified string. Contrast this with the following example.`\n- `Export files with a prefix`\n- `$ git checkout-index --prefix=.merged- Makefile`\n- `This will check out the currently cached copy of Makefile into the file .merged-Makefile.`\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (7 lines)\n- **DESCRIPTION** (3 lines)\n- **OPTIONS** (1 lines) — 9 subsections\n  - -u, --index (2 lines)\n  - -q, --quiet (2 lines)\n  - -f, --force (2 lines)\n  - -a, --all (2 lines)\n  - -n, --no-create (9 lines)\n  - --temp (3 lines)\n  - --stdin (3 lines)\n  - -z (26 lines)\n  - USING --TEMP OR --STAGE=ALL (31 lines)\n- **EXAMPLES** (22 lines)\n- **GIT** (5 lines)\n\n## Full Content\n\n### NAME\n\ngit-checkout-index - Copy files from the index to the working tree\n\n### SYNOPSIS\n\ngit checkout-index [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]\n[--stage=<number>|all]\n[--temp]\n[-z] [--stdin]\n[--] [<file>...]\n\n### DESCRIPTION\n\nWill copy all files listed from the index to the working directory (not overwriting existing\nfiles).\n\n### OPTIONS\n\n#### -u, --index\n\nupdate stat information for the checked out entries in the index file.\n\n#### -q, --quiet\n\nbe quiet if files exist or are not in the index\n\n#### -f, --force\n\nforces overwrite of existing files\n\n#### -a, --all\n\nchecks out all files in the index. Cannot be used together with explicit filenames.\n\n#### -n, --no-create\n\nDon’t checkout new files, only refresh files already checked out.\n\n--prefix=<string>\nWhen creating files, prepend <string> (usually a directory including a trailing /)\n\n--stage=<number>|all\nInstead of checking out unmerged entries, copy out the files from named stage. <number>\nmust be between 1 and 3. Note: --stage=all automatically implies --temp.\n\n#### --temp\n\nInstead of copying the files to the working directory write the content to temporary\nfiles. The temporary name associations will be written to stdout.\n\n#### --stdin\n\nInstead of taking list of paths from the command line, read list of paths from the\nstandard input. Paths are separated by LF (i.e. one path per line) by default.\n\n#### -z\n\nOnly meaningful with --stdin; paths are separated with NUL character instead of LF.\n\n--\nDo not interpret any more arguments as options.\n\nThe order of the flags used to matter, but not anymore.\n\nJust doing git checkout-index does nothing. You probably meant git checkout-index -a. And if\nyou want to force it, you want git checkout-index -f -a.\n\nIntuitiveness is not the goal here. Repeatability is. The reason for the \"no arguments means\nno work\" behavior is that from scripts you are supposed to be able to do:\n\n$ find . -name '*.h' -print0 | xargs -0 git checkout-index -f --\n\n\nwhich will force all existing *.h files to be replaced with their cached copies. If an empty\ncommand line implied \"all\", then this would force-refresh everything in the index, which was\nnot the point. But since git checkout-index accepts --stdin it would be faster to use:\n\n$ find . -name '*.h' -print0 | git checkout-index -f -z --stdin\n\n\nThe -- is just a good idea when you know the rest will be filenames; it will prevent problems\nwith a filename of, for example, -a. Using -- is probably a good policy in scripts.\n\n#### USING --TEMP OR --STAGE=ALL\n\nWhen --temp is used (or implied by --stage=all) git checkout-index will create a temporary\nfile for each index entry being checked out. The index will not be updated with stat\ninformation. These options can be useful if the caller needs all stages of all unmerged\nentries so that the unmerged files can be processed by an external merge tool.\n\nA listing will be written to stdout providing the association of temporary file names to\ntracked path names. The listing format has two variations:\n\n1. tempname TAB path RS\n\nThe first format is what gets used when --stage is omitted or is not --stage=all. The\nfield tempname is the temporary file name holding the file content and path is the\ntracked path name in the index. Only the requested entries are output.\n\n2. stage1temp SP stage2temp SP stage3tmp TAB path RS\n\nThe second format is what gets used when --stage=all. The three stage temporary fields\n(stage1temp, stage2temp, stage3temp) list the name of the temporary file if there is a\nstage entry in the index or .  if there is no stage entry. Paths which only have a stage\n0 entry will always be omitted from the output.\n\nIn both formats RS (the record separator) is newline by default but will be the null byte if\n-z was passed on the command line. The temporary file names are always safe strings; they\nwill never contain directory separators or whitespace characters. The path field is always\nrelative to the current directory and the temporary file names are always relative to the top\nlevel directory.\n\nIf the object being copied out to a temporary file is a symbolic link the content of the link\nwill be written to a normal file. It is up to the end-user or the Porcelain to make use of\nthis information.\n\n### EXAMPLES\n\nTo update and refresh only the files already checked out\n\n$ git checkout-index -n -f -a && git update-index --ignore-missing --refresh\n\n\nUsing git checkout-index to \"export an entire tree\"\nThe prefix ability basically makes it trivial to use git checkout-index as an \"export as\ntree\" function. Just read the desired tree into the index, and do:\n\n$ git checkout-index --prefix=git-export-dir/ -a\n\ngit checkout-index will \"export\" the index into the specified directory.\n\nThe final \"/\" is important. The exported name is literally just prefixed with the\nspecified string. Contrast this with the following example.\n\nExport files with a prefix\n\n$ git checkout-index --prefix=.merged- Makefile\n\nThis will check out the currently cached copy of Makefile into the file .merged-Makefile.\n\n### GIT\n\nPart of the git(1) suite\n\n\n\nGit 2.34.1                                   02/26/2026                        GIT-CHECKOUT-INDEX(1)\n\n"
        }
    ],
    "structuredContent": {
        "command": "git-checkout-index",
        "section": "1",
        "mode": "man",
        "summary": "git-checkout-index - Copy files from the index to the working tree",
        "synopsis": "git checkout-index [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]\n[--stage=<number>|all]\n[--temp]\n[-z] [--stdin]\n[--] [<file>...]",
        "flags": [
            {
                "flag": "-u",
                "long": "--index",
                "arg": null,
                "description": "update stat information for the checked out entries in the index file."
            },
            {
                "flag": "-q",
                "long": "--quiet",
                "arg": null,
                "description": "be quiet if files exist or are not in the index"
            },
            {
                "flag": "-f",
                "long": "--force",
                "arg": null,
                "description": "forces overwrite of existing files"
            },
            {
                "flag": "-a",
                "long": "--all",
                "arg": null,
                "description": "checks out all files in the index. Cannot be used together with explicit filenames."
            },
            {
                "flag": "-n",
                "long": "--no-create",
                "arg": null,
                "description": "Don’t checkout new files, only refresh files already checked out. --prefix=<string> When creating files, prepend <string> (usually a directory including a trailing /) --stage=<number>|all Instead of checking out unmerged entries, copy out the files from named stage. <number> must be between 1 and 3. Note: --stage=all automatically implies --temp."
            },
            {
                "flag": "",
                "long": "--temp",
                "arg": null,
                "description": "Instead of copying the files to the working directory write the content to temporary files. The temporary name associations will be written to stdout."
            },
            {
                "flag": "",
                "long": "--stdin",
                "arg": null,
                "description": "Instead of taking list of paths from the command line, read list of paths from the standard input. Paths are separated by LF (i.e. one path per line) by default."
            },
            {
                "flag": "-z",
                "long": null,
                "arg": null,
                "description": "Only meaningful with --stdin; paths are separated with NUL character instead of LF. -- Do not interpret any more arguments as options. The order of the flags used to matter, but not anymore. Just doing git checkout-index does nothing. You probably meant git checkout-index -a. And if you want to force it, you want git checkout-index -f -a. Intuitiveness is not the goal here. Repeatability is. The reason for the \"no arguments means no work\" behavior is that from scripts you are supposed to be able to do: $ find . -name '*.h' -print0 | xargs -0 git checkout-index -f -- which will force all existing *.h files to be replaced with their cached copies. If an empty command line implied \"all\", then this would force-refresh everything in the index, which was not the point. But since git checkout-index accepts --stdin it would be faster to use: $ find . -name '*.h' -print0 | git checkout-index -f -z --stdin The -- is just a good idea when you know the rest will be filenames; it will prevent problems with a filename of, for example, -a. Using -- is probably a good policy in scripts."
            }
        ],
        "examples": [
            "To update and refresh only the files already checked out",
            "$ git checkout-index -n -f -a && git update-index --ignore-missing --refresh",
            "Using git checkout-index to \"export an entire tree\"",
            "The prefix ability basically makes it trivial to use git checkout-index as an \"export as",
            "tree\" function. Just read the desired tree into the index, and do:",
            "$ git checkout-index --prefix=git-export-dir/ -a",
            "git checkout-index will \"export\" the index into the specified directory.",
            "The final \"/\" is important. The exported name is literally just prefixed with the",
            "specified string. Contrast this with the following example.",
            "Export files with a prefix",
            "$ git checkout-index --prefix=.merged- Makefile",
            "This will check out the currently cached copy of Makefile into the file .merged-Makefile."
        ],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "-u, --index",
                        "lines": 2,
                        "flag": "-u",
                        "long": "--index"
                    },
                    {
                        "name": "-q, --quiet",
                        "lines": 2,
                        "flag": "-q",
                        "long": "--quiet"
                    },
                    {
                        "name": "-f, --force",
                        "lines": 2,
                        "flag": "-f",
                        "long": "--force"
                    },
                    {
                        "name": "-a, --all",
                        "lines": 2,
                        "flag": "-a",
                        "long": "--all"
                    },
                    {
                        "name": "-n, --no-create",
                        "lines": 9,
                        "flag": "-n",
                        "long": "--no-create"
                    },
                    {
                        "name": "--temp",
                        "lines": 3,
                        "long": "--temp"
                    },
                    {
                        "name": "--stdin",
                        "lines": 3,
                        "long": "--stdin"
                    },
                    {
                        "name": "-z",
                        "lines": 26,
                        "flag": "-z"
                    },
                    {
                        "name": "USING --TEMP OR --STAGE=ALL",
                        "lines": 31
                    }
                ]
            },
            {
                "name": "EXAMPLES",
                "lines": 22,
                "subsections": []
            },
            {
                "name": "GIT",
                "lines": 5,
                "subsections": []
            }
        ]
    }
}