{
    "mode": "man",
    "parameter": "git-cat-file",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/git-cat-file/1/json",
    "generated": "2026-06-16T10:48:25Z",
    "synopsis": "git cat-file (-t [--allow-unknown-type]| -s [--allow-unknown-type]| -e | -p | <type> | --textconv | --filters ) [--path=<path>] <object>\ngit cat-file (--batch[=<format>] | --batch-check[=<format>]) [ --textconv | --filters ] [--follow-symlinks]",
    "sections": {
        "NAME": {
            "content": "git-cat-file - Provide content or type and size information for repository objects\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "git cat-file (-t [--allow-unknown-type]| -s [--allow-unknown-type]| -e | -p | <type> | --textconv | --filters ) [--path=<path>] <object>\ngit cat-file (--batch[=<format>] | --batch-check[=<format>]) [ --textconv | --filters ] [--follow-symlinks]\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "In its first form, the command provides the content or the type of an object in the\nrepository. The type is required unless -t or -p is used to find the object type, or -s is\nused to find the object size, or --textconv or --filters is used (which imply type \"blob\").\n\nIn the second form, a list of objects (separated by linefeeds) is provided on stdin, and the\nSHA-1, type, and size of each object is printed on stdout. The output format can be\noverridden using the optional <format> argument. If either --textconv or --filters was\nspecified, the input is expected to list the object names followed by the path name,\nseparated by a single whitespace, so that the appropriate drivers can be determined.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "<object>\nThe name of the object to show. For a more complete list of ways to spell object names,\nsee the \"SPECIFYING REVISIONS\" section in gitrevisions(7).\n",
            "subsections": [
                {
                    "name": "-t",
                    "content": "Instead of the content, show the object type identified by <object>.\n",
                    "flag": "-t"
                },
                {
                    "name": "-s",
                    "content": "Instead of the content, show the object size identified by <object>.\n",
                    "flag": "-s"
                },
                {
                    "name": "-e",
                    "content": "Exit with zero status if <object> exists and is a valid object. If <object> is of an\ninvalid format exit with non-zero and emits an error on stderr.\n",
                    "flag": "-e"
                },
                {
                    "name": "-p",
                    "content": "Pretty-print the contents of <object> based on its type.\n\n<type>\nTypically this matches the real type of <object> but asking for a type that can trivially\nbe dereferenced from the given <object> is also permitted. An example is to ask for a\n\"tree\" with <object> being a commit object that contains it, or to ask for a \"blob\" with\n<object> being a tag object that points at it.\n",
                    "flag": "-p"
                },
                {
                    "name": "--textconv",
                    "content": "Show the content as transformed by a textconv filter. In this case, <object> has to be of\nthe form <tree-ish>:<path>, or :<path> in order to apply the filter to the content\nrecorded in the index at <path>.\n",
                    "long": "--textconv"
                },
                {
                    "name": "--filters",
                    "content": "Show the content as converted by the filters configured in the current working tree for\nthe given <path> (i.e. smudge filters, end-of-line conversion, etc). In this case,\n<object> has to be of the form <tree-ish>:<path>, or :<path>.\n\n--path=<path>\nFor use with --textconv or --filters, to allow specifying an object name and a path\nseparately, e.g. when it is difficult to figure out the revision from which the blob\ncame.\n\n--batch, --batch=<format>\nPrint object information and contents for each object provided on stdin. May not be\ncombined with any other options or arguments except --textconv or --filters, in which\ncase the input lines also need to specify the path, separated by whitespace. See the\nsection BATCH OUTPUT below for details.\n\n--batch-check, --batch-check=<format>\nPrint object information for each object provided on stdin. May not be combined with any\nother options or arguments except --textconv or --filters, in which case the input lines\nalso need to specify the path, separated by whitespace. See the section BATCH OUTPUT\nbelow for details.\n",
                    "long": "--filters"
                },
                {
                    "name": "--batch-all-objects",
                    "content": "Instead of reading a list of objects on stdin, perform the requested batch operation on\nall objects in the repository and any alternate object stores (not just reachable\nobjects). Requires --batch or --batch-check be specified. By default, the objects are\nvisited in order sorted by their hashes; see also --unordered below. Objects are\npresented as-is, without respecting the \"replace\" mechanism of git-replace(1).\n",
                    "long": "--batch-all-objects"
                },
                {
                    "name": "--buffer",
                    "content": "Normally batch output is flushed after each object is output, so that a process can\ninteractively read and write from cat-file. With this option, the output uses normal\nstdio buffering; this is much more efficient when invoking --batch-check on a large\nnumber of objects.\n",
                    "long": "--buffer"
                },
                {
                    "name": "--unordered",
                    "content": "When --batch-all-objects is in use, visit objects in an order which may be more efficient\nfor accessing the object contents than hash order. The exact details of the order are\nunspecified, but if you do not require a specific order, this should generally result in\nfaster output, especially with --batch. Note that cat-file will still show each object\nonly once, even if it is stored multiple times in the repository.\n",
                    "long": "--unordered"
                },
                {
                    "name": "--allow-unknown-type",
                    "content": "Allow -s or -t to query broken/corrupt objects of unknown type.\n",
                    "long": "--allow-unknown-type"
                },
                {
                    "name": "--follow-symlinks",
                    "content": "With --batch or --batch-check, follow symlinks inside the repository when requesting\nobjects with extended SHA-1 expressions of the form tree-ish:path-in-tree. Instead of\nproviding output about the link itself, provide output about the linked-to object. If a\nsymlink points outside the tree-ish (e.g. a link to /foo or a root-level link to ../foo),\nthe portion of the link which is outside the tree will be printed.\n\nThis option does not (currently) work correctly when an object in the index is specified\n(e.g.  :link instead of HEAD:link) rather than one in the tree.\n\nThis option cannot (currently) be used unless --batch or --batch-check is used.\n\nFor example, consider a git repository containing:\n\nf: a file containing \"hello\\n\"\nlink: a symlink to f\ndir/link: a symlink to ../f\nplink: a symlink to ../f\nalink: a symlink to /etc/passwd\n\nFor a regular file f, echo HEAD:f | git cat-file --batch would print\n\nce013625030ba8dba906f756967f9e9ca394464a blob 6\n\nAnd echo HEAD:link | git cat-file --batch --follow-symlinks would print the same thing,\nas would HEAD:dir/link, as they both point at HEAD:f.\n\nWithout --follow-symlinks, these would print data about the symlink itself. In the case\nof HEAD:link, you would see\n\n4d1ae35ba2c8ec712fa2a379db44ad639ca277bd blob 1\n\nBoth plink and alink point outside the tree, so they would respectively print:\n\nsymlink 4\n../f\n\nsymlink 11\n/etc/passwd\n",
                    "long": "--follow-symlinks"
                }
            ]
        },
        "OUTPUT": {
            "content": "If -t is specified, one of the <type>.\n\nIf -s is specified, the size of the <object> in bytes.\n\nIf -e is specified, no output, unless the <object> is malformed.\n\nIf -p is specified, the contents of <object> are pretty-printed.\n\nIf <type> is specified, the raw (though uncompressed) contents of the <object> will be\nreturned.\n",
            "subsections": []
        },
        "BATCH OUTPUT": {
            "content": "If --batch or --batch-check is given, cat-file will read objects from stdin, one per line,\nand print information about them. By default, the whole line is considered as an object, as\nif it were fed to git-rev-parse(1).\n\nYou can specify the information shown for each object by using a custom <format>. The\n<format> is copied literally to stdout for each object, with placeholders of the form %(atom)\nexpanded, followed by a newline. The available atoms are:\n",
            "subsections": [
                {
                    "name": "objectname",
                    "content": "The full hex representation of the object name.\n"
                },
                {
                    "name": "objecttype",
                    "content": "The type of the object (the same as cat-file -t reports).\n"
                },
                {
                    "name": "objectsize",
                    "content": "The size, in bytes, of the object (the same as cat-file -s reports).\n"
                },
                {
                    "name": "objectsize:disk",
                    "content": "The size, in bytes, that the object takes up on disk. See the note about on-disk sizes in\nthe CAVEATS section below.\n"
                },
                {
                    "name": "deltabase",
                    "content": "If the object is stored as a delta on-disk, this expands to the full hex representation\nof the delta base object name. Otherwise, expands to the null OID (all zeroes). See\nCAVEATS below.\n"
                },
                {
                    "name": "rest",
                    "content": "If this atom is used in the output string, input lines are split at the first whitespace\nboundary. All characters before that whitespace are considered to be the object name;\ncharacters after that first run of whitespace (i.e., the \"rest\" of the line) are output\nin place of the %(rest) atom.\n\nIf no format is specified, the default format is %(objectname) %(objecttype) %(objectsize).\n\nIf --batch is specified, the object information is followed by the object contents\n(consisting of %(objectsize) bytes), followed by a newline.\n\nFor example, --batch without a custom format would produce:\n\n<oid> SP <type> SP <size> LF\n<contents> LF\n\n\nWhereas --batch-check='%(objectname) %(objecttype)' would produce:\n\n<oid> SP <type> LF\n\n\nIf a name is specified on stdin that cannot be resolved to an object in the repository, then\ncat-file will ignore any custom format and print:\n\n<object> SP missing LF\n\n\nIf a name is specified that might refer to more than one object (an ambiguous short sha),\nthen cat-file will ignore any custom format and print:\n\n<object> SP ambiguous LF\n\n\nIf --follow-symlinks is used, and a symlink in the repository points outside the repository,\nthen cat-file will ignore any custom format and print:\n\nsymlink SP <size> LF\n<symlink> LF\n\n\nThe symlink will either be absolute (beginning with a /), or relative to the tree root. For\ninstance, if dir/link points to ../../foo, then <symlink> will be ../foo. <size> is the size\nof the symlink in bytes.\n\nIf --follow-symlinks is used, the following error messages will be displayed:\n\n<object> SP missing LF\n\n\nis printed when the initial symlink requested does not exist.\n\ndangling SP <size> LF\n<object> LF\n\n\nis printed when the initial symlink exists, but something that it (transitive-of) points to\ndoes not.\n\nloop SP <size> LF\n<object> LF\n\n\nis printed for symlink loops (or any symlinks that require more than 40 link resolutions to\nresolve).\n\nnotdir SP <size> LF\n<object> LF\n\n\nis printed when, during symlink resolution, a file is used as a directory name.\n"
                }
            ]
        },
        "CAVEATS": {
            "content": "Note that the sizes of objects on disk are reported accurately, but care should be taken in\ndrawing conclusions about which refs or objects are responsible for disk usage. The size of a\npacked non-delta object may be much larger than the size of objects which delta against it,\nbut the choice of which object is the base and which is the delta is arbitrary and is subject\nto change during a repack.\n\nNote also that multiple copies of an object may be present in the object database; in this\ncase, it is undefined which copy’s size or delta base will be reported.\n",
            "subsections": []
        },
        "GIT": {
            "content": "Part of the git(1) suite\n\n\n\nGit 2.34.1                                   02/26/2026                              GIT-CAT-FILE(1)",
            "subsections": []
        }
    },
    "summary": "git-cat-file - Provide content or type and size information for repository objects",
    "flags": [
        {
            "flag": "-t",
            "long": null,
            "arg": null,
            "description": "Instead of the content, show the object type identified by <object>."
        },
        {
            "flag": "-s",
            "long": null,
            "arg": null,
            "description": "Instead of the content, show the object size identified by <object>."
        },
        {
            "flag": "-e",
            "long": null,
            "arg": null,
            "description": "Exit with zero status if <object> exists and is a valid object. If <object> is of an invalid format exit with non-zero and emits an error on stderr."
        },
        {
            "flag": "-p",
            "long": null,
            "arg": null,
            "description": "Pretty-print the contents of <object> based on its type. <type> Typically this matches the real type of <object> but asking for a type that can trivially be dereferenced from the given <object> is also permitted. An example is to ask for a \"tree\" with <object> being a commit object that contains it, or to ask for a \"blob\" with <object> being a tag object that points at it."
        },
        {
            "flag": "",
            "long": "--textconv",
            "arg": null,
            "description": "Show the content as transformed by a textconv filter. In this case, <object> has to be of the form <tree-ish>:<path>, or :<path> in order to apply the filter to the content recorded in the index at <path>."
        },
        {
            "flag": "",
            "long": "--filters",
            "arg": null,
            "description": "Show the content as converted by the filters configured in the current working tree for the given <path> (i.e. smudge filters, end-of-line conversion, etc). In this case, <object> has to be of the form <tree-ish>:<path>, or :<path>. --path=<path> For use with --textconv or --filters, to allow specifying an object name and a path separately, e.g. when it is difficult to figure out the revision from which the blob came. --batch, --batch=<format> Print object information and contents for each object provided on stdin. May not be combined with any other options or arguments except --textconv or --filters, in which case the input lines also need to specify the path, separated by whitespace. See the section BATCH OUTPUT below for details. --batch-check, --batch-check=<format> Print object information for each object provided on stdin. May not be combined with any other options or arguments except --textconv or --filters, in which case the input lines also need to specify the path, separated by whitespace. See the section BATCH OUTPUT below for details."
        },
        {
            "flag": "",
            "long": "--batch-all-objects",
            "arg": null,
            "description": "Instead of reading a list of objects on stdin, perform the requested batch operation on all objects in the repository and any alternate object stores (not just reachable objects). Requires --batch or --batch-check be specified. By default, the objects are visited in order sorted by their hashes; see also --unordered below. Objects are presented as-is, without respecting the \"replace\" mechanism of git-replace(1)."
        },
        {
            "flag": "",
            "long": "--buffer",
            "arg": null,
            "description": "Normally batch output is flushed after each object is output, so that a process can interactively read and write from cat-file. With this option, the output uses normal stdio buffering; this is much more efficient when invoking --batch-check on a large number of objects."
        },
        {
            "flag": "",
            "long": "--unordered",
            "arg": null,
            "description": "When --batch-all-objects is in use, visit objects in an order which may be more efficient for accessing the object contents than hash order. The exact details of the order are unspecified, but if you do not require a specific order, this should generally result in faster output, especially with --batch. Note that cat-file will still show each object only once, even if it is stored multiple times in the repository."
        },
        {
            "flag": "",
            "long": "--allow-unknown-type",
            "arg": null,
            "description": "Allow -s or -t to query broken/corrupt objects of unknown type."
        },
        {
            "flag": "",
            "long": "--follow-symlinks",
            "arg": null,
            "description": "With --batch or --batch-check, follow symlinks inside the repository when requesting objects with extended SHA-1 expressions of the form tree-ish:path-in-tree. Instead of providing output about the link itself, provide output about the linked-to object. If a symlink points outside the tree-ish (e.g. a link to /foo or a root-level link to ../foo), the portion of the link which is outside the tree will be printed. This option does not (currently) work correctly when an object in the index is specified (e.g. :link instead of HEAD:link) rather than one in the tree. This option cannot (currently) be used unless --batch or --batch-check is used. For example, consider a git repository containing: f: a file containing \"hello\\n\" link: a symlink to f dir/link: a symlink to ../f plink: a symlink to ../f alink: a symlink to /etc/passwd For a regular file f, echo HEAD:f | git cat-file --batch would print ce013625030ba8dba906f756967f9e9ca394464a blob 6 And echo HEAD:link | git cat-file --batch --follow-symlinks would print the same thing, as would HEAD:dir/link, as they both point at HEAD:f. Without --follow-symlinks, these would print data about the symlink itself. In the case of HEAD:link, you would see 4d1ae35ba2c8ec712fa2a379db44ad639ca277bd blob 1 Both plink and alink point outside the tree, so they would respectively print: symlink 4 ../f symlink 11 /etc/passwd"
        }
    ],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Provide content or type and size information for Git repository objects.",
        "examples": [
            {
                "description": "Get the [s]ize of the `HEAD` commit in bytes",
                "command": "git cat-file -s HEAD"
            },
            {
                "description": "Get the [t]ype (blob, tree, commit, tag) of a given Git object",
                "command": "git cat-file -t {{8c442dc3}}"
            },
            {
                "description": "Pretty-[p]rint the contents of a given Git object based on its type",
                "command": "git cat-file -p {{HEAD~2}}"
            }
        ]
    }
}