{
    "content": [
        {
            "type": "text",
            "text": "# git-archive (info)\n\n## NAME\n\ngit-archive - Create an archive of files from a named tree\n\n## SYNOPSIS\n\ngit archive [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]\n[-o <file> | --output=<file>] [--worktree-attributes]\n[--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>\n[<path>...]\n\n## DESCRIPTION\n\nCreates an archive of the specified format containing the tree\nstructure for the named tree, and writes it out to the standard output.\nIf <prefix> is specified it is prepended to the filenames in the\narchive.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS** (3 subsections)\n- **BACKEND EXTRA OPTIONS**\n- **CONFIGURATION**\n- **ATTRIBUTES**\n- **EXAMPLES**\n- **SEE ALSO**\n- **GIT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "git-archive",
        "section": "",
        "mode": "info",
        "summary": "git-archive - Create an archive of files from a named tree",
        "synopsis": "git archive [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]\n[-o <file> | --output=<file>] [--worktree-attributes]\n[--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>\n[<path>...]",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [
            {
                "flag": "-l",
                "long": "--list",
                "arg": null,
                "description": "Show all available formats."
            },
            {
                "flag": "-v",
                "long": "--verbose",
                "arg": null,
                "description": "Report progress to stderr. --prefix=<prefix>/ Prepend <prefix>/ to each filename in the archive. -o <file>, --output=<file> Write the archive to <file> instead of stdout. --add-file=<file> Add a non-tracked file to the archive. Can be repeated to add multiple files. The path of the file in the archive is built by concatenating the value for --prefix (if any) and the basename of <file>."
            },
            {
                "flag": "",
                "long": "--worktree-attributes",
                "arg": null,
                "description": "Look for attributes in .gitattributes files in the working tree as well (see the section called \"ATTRIBUTES\"). <extra> This can be any options that the archiver backend understands. See next section. --remote=<repo> Instead of making a tar archive from the local repository, retrieve a tar archive from a remote repository. Note that the remote repository may place restrictions on which sha1 expressions may be allowed in <tree-ish>. See git-upload-archive(1) for details. --exec=<git-upload-archive> Used with --remote to specify the path to the git-upload-archive on the remote side. <tree-ish> The tree or commit to produce an archive for. <path> Without an optional path parameter, all files and subdirectories of the current working directory are included in the archive. If one or more paths are specified, only these are included."
            }
        ],
        "examples": [
            "git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf",
            "-)",
            "Create a tar archive that contains the contents of the latest",
            "commit on the current branch, and extract it in the /var/tmp/junk",
            "directory.",
            "git archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip",
            ">git-1.4.0.tar.gz",
            "Create a compressed tarball for v1.4.0 release.",
            "git archive --format=tar.gz --prefix=git-1.4.0/ v1.4.0",
            ">git-1.4.0.tar.gz",
            "Same as above, but using the builtin tar.gz handling.",
            "git archive --prefix=git-1.4.0/ -o git-1.4.0.tar.gz v1.4.0",
            "Same as above, but the format is inferred from the output file.",
            "git archive --format=tar --prefix=git-1.4.0/ v1.4.0^{tree} | gzip",
            ">git-1.4.0.tar.gz",
            "Create a compressed tarball for v1.4.0 release, but without a",
            "global extended pax header.",
            "git archive --format=zip --prefix=git-docs/ HEAD:Documentation/ >",
            "git-1.4.0-docs.zip",
            "Put everything in the current head's Documentation/ directory into",
            "git-1.4.0-docs.zip, with the prefix git-docs/.",
            "git archive -o latest.zip HEAD",
            "Create a Zip archive that contains the contents of the latest",
            "commit on the current branch. Note that the output format is",
            "inferred by the extension of the output file.",
            "git config tar.tar.xz.command \"xz -c\"",
            "Configure a \"tar.xz\" format for making LZMA-compressed tarfiles.",
            "You can use it specifying --format=tar.xz, or by creating an output",
            "file like -o foo.tar.xz."
        ],
        "see_also": [
            {
                "name": "gitattributes",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/gitattributes/5/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 7,
                "subsections": [
                    {
                        "name": "-l, --list",
                        "lines": 2,
                        "flag": "-l",
                        "long": "--list"
                    },
                    {
                        "name": "-v, --verbose",
                        "lines": 14,
                        "flag": "-v",
                        "long": "--verbose"
                    },
                    {
                        "name": "--worktree-attributes",
                        "lines": 25,
                        "long": "--worktree-attributes"
                    }
                ]
            },
            {
                "name": "BACKEND EXTRA OPTIONS",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "CONFIGURATION",
                "lines": 25,
                "subsections": []
            },
            {
                "name": "ATTRIBUTES",
                "lines": 17,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 37,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "GIT",
                "lines": 3,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "git-archive - Create an archive of files from a named tree\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "git archive [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]\n[-o <file> | --output=<file>] [--worktree-attributes]\n[--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>\n[<path>...]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Creates an archive of the specified format containing the tree\nstructure for the named tree, and writes it out to the standard output.\nIf <prefix> is specified it is prepended to the filenames in the\narchive.\n\ngit archive behaves differently when given a tree ID versus when given\na commit ID or tag ID. In the first case the current time is used as\nthe modification time of each file in the archive. In the latter case\nthe commit time as recorded in the referenced commit object is used\ninstead. Additionally the commit ID is stored in a global extended pax\nheader if the tar format is used; it can be extracted using git\nget-tar-commit-id. In ZIP files it is stored as a file comment.\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "--format=<fmt>\nFormat of the resulting archive: tar or zip. If this option is not\ngiven, and the output file is specified, the format is inferred\nfrom the filename if possible (e.g. writing to \"foo.zip\" makes the\noutput to be in the zip format). Otherwise the output format is\ntar.\n",
                "subsections": [
                    {
                        "name": "-l, --list",
                        "content": "Show all available formats.\n",
                        "flag": "-l",
                        "long": "--list"
                    },
                    {
                        "name": "-v, --verbose",
                        "content": "Report progress to stderr.\n\n--prefix=<prefix>/\nPrepend <prefix>/ to each filename in the archive.\n\n-o <file>, --output=<file>\nWrite the archive to <file> instead of stdout.\n\n--add-file=<file>\nAdd a non-tracked file to the archive. Can be repeated to add\nmultiple files. The path of the file in the archive is built by\nconcatenating the value for --prefix (if any) and the basename of\n<file>.\n",
                        "flag": "-v",
                        "long": "--verbose"
                    },
                    {
                        "name": "--worktree-attributes",
                        "content": "Look for attributes in .gitattributes files in the working tree as\nwell (see the section called \"ATTRIBUTES\").\n\n<extra>\nThis can be any options that the archiver backend understands. See\nnext section.\n\n--remote=<repo>\nInstead of making a tar archive from the local repository, retrieve\na tar archive from a remote repository. Note that the remote\nrepository may place restrictions on which sha1 expressions may be\nallowed in <tree-ish>. See git-upload-archive(1) for details.\n\n--exec=<git-upload-archive>\nUsed with --remote to specify the path to the git-upload-archive on\nthe remote side.\n\n<tree-ish>\nThe tree or commit to produce an archive for.\n\n<path>\nWithout an optional path parameter, all files and subdirectories of\nthe current working directory are included in the archive. If one\nor more paths are specified, only these are included.\n",
                        "long": "--worktree-attributes"
                    }
                ]
            },
            "BACKEND EXTRA OPTIONS": {
                "content": "zip\n-<digit>\nSpecify compression level. Larger values allow the command to spend\nmore time to compress to smaller size. Supported values are from -0\n(store-only) to -9 (best ratio). Default is -6 if not given.\n\ntar\n-<number>\nSpecify compression level. The value will be passed to the\ncompression command configured in tar.<format>.command. See manual\npage of the configured command for the list of supported levels and\nthe default level if this option isn't specified.\n",
                "subsections": []
            },
            "CONFIGURATION": {
                "content": "tar.umask\nThis variable can be used to restrict the permission bits of tar\narchive entries. The default is 0002, which turns off the world\nwrite bit. The special value \"user\" indicates that the archiving\nuser's umask will be used instead. See umask(2) for details. If\n--remote is used then only the configuration of the remote\nrepository takes effect.\n\ntar.<format>.command\nThis variable specifies a shell command through which the tar\noutput generated by git archive should be piped. The command is\nexecuted using the shell with the generated tar file on its\nstandard input, and should produce the final output on its standard\noutput. Any compression-level options will be passed to the command\n(e.g., \"-9\"). An output file with the same extension as <format>\nwill be use this format if no other format is given.\n\nThe \"tar.gz\" and \"tgz\" formats are defined automatically and\ndefault to gzip -cn. You may override them with custom commands.\n\ntar.<format>.remote\nIf true, enable <format> for use by remote clients via git-upload-\narchive(1). Defaults to false for user-defined formats, but true\nfor the \"tar.gz\" and \"tgz\" formats.\n",
                "subsections": []
            },
            "ATTRIBUTES": {
                "content": "export-ignore\nFiles and directories with the attribute export-ignore won't be\nadded to archive files. See gitattributes(5) for details.\n\nexport-subst\nIf the attribute export-subst is set for a file then Git will\nexpand several placeholders when adding this file to an archive.\nSee gitattributes(5) for details.\n\nNote that attributes are by default taken from the .gitattributes files\nin the tree that is being archived. If you want to tweak the way the\noutput is generated after the fact (e.g. you committed without adding\nan appropriate export-ignore in its .gitattributes), adjust the checked\nout .gitattributes file as necessary and use --worktree-attributes\noption. Alternatively you can keep necessary attributes that should\napply while archiving any tree in your $GITDIR/info/attributes file.\n",
                "subsections": []
            },
            "EXAMPLES": {
                "content": "git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf\n-)\nCreate a tar archive that contains the contents of the latest\ncommit on the current branch, and extract it in the /var/tmp/junk\ndirectory.\n\ngit archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip\n>git-1.4.0.tar.gz\nCreate a compressed tarball for v1.4.0 release.\n\ngit archive --format=tar.gz --prefix=git-1.4.0/ v1.4.0\n>git-1.4.0.tar.gz\nSame as above, but using the builtin tar.gz handling.\n\ngit archive --prefix=git-1.4.0/ -o git-1.4.0.tar.gz v1.4.0\nSame as above, but the format is inferred from the output file.\n\ngit archive --format=tar --prefix=git-1.4.0/ v1.4.0^{tree} | gzip\n>git-1.4.0.tar.gz\nCreate a compressed tarball for v1.4.0 release, but without a\nglobal extended pax header.\n\ngit archive --format=zip --prefix=git-docs/ HEAD:Documentation/ >\ngit-1.4.0-docs.zip\nPut everything in the current head's Documentation/ directory into\ngit-1.4.0-docs.zip, with the prefix git-docs/.\n\ngit archive -o latest.zip HEAD\nCreate a Zip archive that contains the contents of the latest\ncommit on the current branch. Note that the output format is\ninferred by the extension of the output file.\n\ngit config tar.tar.xz.command \"xz -c\"\nConfigure a \"tar.xz\" format for making LZMA-compressed tarfiles.\nYou can use it specifying --format=tar.xz, or by creating an output\nfile like -o foo.tar.xz.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "gitattributes(5)\n",
                "subsections": []
            },
            "GIT": {
                "content": "Part of the git(1) suite\n\nGit 2.34.1                        02/26/2026                    GIT-ARCHIVE(1)",
                "subsections": []
            }
        }
    }
}