2 .\" Title: git-cat-file
3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
7 .\" Source: Git 2.42.0.rc0
10 .TH "GIT\-CAT\-FILE" "1" "2023\-08\-04" "Git 2\&.42\&.0\&.rc0" "Git Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 git-cat-file \- Provide content or type and size information for repository objects
35 \fIgit cat\-file\fR <type> <object>
36 \fIgit cat\-file\fR (\-e | \-p) <object>
37 \fIgit cat\-file\fR (\-t | \-s) [\-\-allow\-unknown\-type] <object>
38 \fIgit cat\-file\fR (\-\-batch | \-\-batch\-check | \-\-batch\-command) [\-\-batch\-all\-objects]
39 [\-\-buffer] [\-\-follow\-symlinks] [\-\-unordered]
40 [\-\-textconv | \-\-filters] [\-Z]
41 \fIgit cat\-file\fR (\-\-textconv | \-\-filters)
42 [<rev>:<path|tree\-ish> | \-\-path=<path|tree\-ish> <rev>]
47 In its first form, the command provides the content or the type of an object in the repository\&. The type is required unless \fB\-t\fR or \fB\-p\fR is used to find the object type, or \fB\-s\fR is used to find the object size, or \fB\-\-textconv\fR or \fB\-\-filters\fR is used (which imply type "blob")\&.
49 In the second form, a list of objects (separated by linefeeds) is provided on stdin, and the SHA\-1, type, and size of each object is printed on stdout\&. The output format can be overridden using the optional \fB<format>\fR argument\&. If either \fB\-\-textconv\fR or \fB\-\-filters\fR was specified, the input is expected to list the object names followed by the path name, separated by a single whitespace, so that the appropriate drivers can be determined\&.
54 The name of the object to show\&. For a more complete list of ways to spell object names, see the "SPECIFYING REVISIONS" section in
55 \fBgitrevisions\fR(7)\&.
60 Instead of the content, show the object type identified by
66 Instead of the content, show the object size identified by
67 \fB<object>\fR\&. If used with
68 \fB\-\-use\-mailmap\fR
69 option, will show the size of updated object after replacing idents using the mailmap mechanism\&.
74 Exit with zero status if
76 exists and is a valid object\&. If
78 is of an invalid format exit with non\-zero and emits an error on stderr\&.
83 Pretty\-print the contents of
90 Typically this matches the real type of
92 but asking for a type that can trivially be dereferenced from the given
94 is also permitted\&. An example is to ask for a "tree" with
96 being a commit object that contains it, or to ask for a "blob" with
98 being a tag object that points at it\&.
101 \-\-[no\-]mailmap, \-\-[no\-]use\-mailmap
103 Use mailmap file to map author, committer and tagger names and email addresses to canonical real names and email addresses\&. See
104 \fBgit-shortlog\fR(1)\&.
109 Show the content as transformed by a textconv filter\&. In this case,
111 has to be of the form
112 \fB<tree\-ish>:<path>\fR, or
114 in order to apply the filter to the content recorded in the index at
120 Show the content as converted by the filters configured in the current working tree for the given
122 (i\&.e\&. smudge filters, end\-of\-line conversion, etc)\&. In this case,
124 has to be of the form
125 \fB<tree\-ish>:<path>\fR, or
134 \fB\-\-filters\fR, 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\&.
137 \-\-batch, \-\-batch=<format>
139 Print object information and contents for each object provided on stdin\&. May not be combined with any other options or arguments except
141 \fB\-\-filters\fR, or
142 \fB\-\-use\-mailmap\fR\&.
155 \fB\-\-filters\fR, the input lines must specify the path, separated by whitespace\&. See the section
169 \fB\-\-use\-mailmap\fR, for commit and tag objects, the contents part of the output shows the identities replaced using the mailmap mechanism, while the information part of the output shows the size of the object as if it actually recorded the replacement identities\&.
173 \-\-batch\-check, \-\-batch\-check=<format>
175 Print object information for each object provided on stdin\&. May not be combined with any other options or arguments except
179 \fB\-\-use\-mailmap\fR\&.
192 \fB\-\-filters\fR, the input lines must specify the path, separated by whitespace\&. See the section
206 \fB\-\-use\-mailmap\fR, for commit and tag objects, the printed object information shows the size of the object as if the identities recorded in it were replaced by the mailmap mechanism\&.
210 \-\-batch\-command, \-\-batch\-command=<format>
212 Enter a command mode that reads commands and arguments from stdin\&. May only be combined with
215 \fB\-\-use\-mailmap\fR
230 \fB\-\-filters\fR, the input lines must specify the path, separated by whitespace\&. See the section
244 \fB\-\-use\-mailmap\fR, for commit and tag objects, the
246 command shows the identities replaced using the mailmap mechanism, while the
248 command shows the size of the object as if it actually recorded the replacement identities\&.
251 \fB\-\-batch\-command\fR
252 recognizes the following commands:
256 Print object contents for object reference
257 \fB<object>\fR\&. This corresponds to the output of
263 Print object info for object reference
264 \fB<object>\fR\&. This corresponds to the output of
265 \fB\-\-batch\-check\fR\&.
272 to execute all preceding commands that were issued since the beginning or since the last flush was issued\&. When
274 is used, no output will come until a
278 is not used, commands are flushed each time without issuing
283 \-\-batch\-all\-objects
285 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
288 \fB\-\-batch\-check\fR
289 be specified\&. By default, the objects are visited in order sorted by their hashes; see also
291 below\&. Objects are presented as\-is, without respecting the "replace" mechanism of
292 \fBgit-replace\fR(1)\&.
297 Normally batch output is flushed after each object is output, so that a process can interactively read and write from
298 \fBcat\-file\fR\&. With this option, the output uses normal stdio buffering; this is much more efficient when invoking
299 \fB\-\-batch\-check\fR
301 \fB\-\-batch\-command\fR
302 on a large number of objects\&.
308 \fB\-\-batch\-all\-objects\fR
309 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
310 \fB\-\-batch\fR\&. Note that
312 will still show each object only once, even if it is stored multiple times in the repository\&.
315 \-\-allow\-unknown\-type
321 to query broken/corrupt objects of unknown type\&.
329 \fB\-\-batch\-check\fR, 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
331 or a root\-level link to
332 \fB\&.\&./foo\fR), the portion of the link which is outside the tree will be printed\&.
334 This option does not (currently) work correctly when an object in the index is specified (e\&.g\&.
337 \fBHEAD:link\fR) rather than one in the tree\&.
339 This option cannot (currently) be used unless
342 \fB\-\-batch\-check\fR
345 For example, consider a git repository containing:
351 f: a file containing "hello\en"
353 dir/link: a symlink to \&.\&./f
354 plink: a symlink to \&.\&./f
355 alink: a symlink to /etc/passwd
363 \fBecho HEAD:f | git cat\-file \-\-batch\fR
370 ce013625030ba8dba906f756967f9e9ca394464a blob 6
377 \fBecho HEAD:link | git cat\-file \-\-batch \-\-follow\-symlinks\fR
378 would print the same thing, as would
379 \fBHEAD:dir/link\fR, as they both point at
383 \fB\-\-follow\-symlinks\fR, these would print data about the symlink itself\&. In the case of
384 \fBHEAD:link\fR, you would see
390 4d1ae35ba2c8ec712fa2a379db44ad639ca277bd blob 1
400 point outside the tree, so they would respectively print:
429 \fB\-\-batch\-check\fR, or
430 \fB\-\-batch\-command\fR; input and output is NUL\-delimited instead of newline\-delimited\&.
437 \fB\-\-batch\-check\fR, or
438 \fB\-\-batch\-command\fR; input is NUL\-delimited instead of newline\-delimited\&. This option is deprecated in favor of
440 as the output can otherwise be ambiguous\&.
444 If \fB\-t\fR is specified, one of the \fB<type>\fR\&.
446 If \fB\-s\fR is specified, the size of the \fB<object>\fR in bytes\&.
448 If \fB\-e\fR is specified, no output, unless the \fB<object>\fR is malformed\&.
450 If \fB\-p\fR is specified, the contents of \fB<object>\fR are pretty\-printed\&.
452 If \fB<type>\fR is specified, the raw (though uncompressed) contents of the \fB<object>\fR will be returned\&.
455 If \fB\-\-batch\fR or \fB\-\-batch\-check\fR is given, \fBcat\-file\fR will read objects from stdin, one per line, and print information about them\&. By default, the whole line is considered as an object, as if it were fed to \fBgit-rev-parse\fR(1)\&.
457 When \fB\-\-batch\-command\fR is given, \fBcat\-file\fR will read commands from stdin, one per line, and print information based on the command given\&. With \fB\-\-batch\-command\fR, the \fBinfo\fR command followed by an object will print information about the object the same way \fB\-\-batch\-check\fR would, and the \fBcontents\fR command followed by an object prints contents in the same way \fB\-\-batch\fR would\&.
459 You can specify the information shown for each object by using a custom \fB<format>\fR\&. The \fB<format>\fR is copied literally to stdout for each object, with placeholders of the form \fB%(atom)\fR expanded, followed by a newline\&. The available atoms are:
463 The full hex representation of the object name\&.
468 The type of the object (the same as
475 The size, in bytes, of the object (the same as
480 \fBobjectsize:disk\fR
482 The size, in bytes, that the object takes up on disk\&. See the note about on\-disk sizes in the
489 If the object is stored as a delta on\-disk, this expands to the full hex representation of the delta base object name\&. Otherwise, expands to the null OID (all zeroes)\&. See
496 If this atom is used in the output string, input lines are split at the first whitespace boundary\&. All characters before that whitespace are considered to be the object name; characters after that first run of whitespace (i\&.e\&., the "rest" of the line) are output in place of the
501 If no format is specified, the default format is \fB%(objectname) %(objecttype) %(objectsize)\fR\&.
503 If \fB\-\-batch\fR is specified, or if \fB\-\-batch\-command\fR is used with the \fBcontents\fR command, the object information is followed by the object contents (consisting of \fB%(objectsize)\fR bytes), followed by a newline\&.
505 For example, \fB\-\-batch\fR without a custom format would produce:
511 <oid> SP <type> SP <size> LF
519 Whereas \fB\-\-batch\-check=\*(Aq%(objectname) %(objecttype)\*(Aq\fR would produce:
532 If a name is specified on stdin that cannot be resolved to an object in the repository, then \fBcat\-file\fR will ignore any custom format and print:
538 <object> SP missing LF
545 If a name is specified that might refer to more than one object (an ambiguous short sha), then \fBcat\-file\fR will ignore any custom format and print:
551 <object> SP ambiguous LF
558 If \fB\-\-follow\-symlinks\fR is used, and a symlink in the repository points outside the repository, then \fBcat\-file\fR will ignore any custom format and print:
572 The symlink will either be absolute (beginning with a \fB/\fR), or relative to the tree root\&. For instance, if dir/link points to \fB\&.\&./\&.\&./foo\fR, then \fB<symlink>\fR will be \fB\&.\&./foo\fR\&. \fB<size>\fR is the size of the symlink in bytes\&.
574 If \fB\-\-follow\-symlinks\fR is used, the following error messages will be displayed:
580 <object> SP missing LF
587 is printed when the initial symlink requested does not exist\&.
593 dangling SP <size> LF
601 is printed when the initial symlink exists, but something that it (transitive\-of) points to does not\&.
615 is printed for symlink loops (or any symlinks that require more than 40 link resolutions to resolve)\&.
629 is printed when, during symlink resolution, a file is used as a directory name\&.
631 Alternatively, when \fB\-Z\fR is passed, the line feeds in any of the above examples are replaced with NUL terminators\&. This ensures that output will be parsable if the output itself would contain a linefeed and is thus recommended for scripting purposes\&.
634 Note that the sizes of objects on disk are reported accurately, but care should be taken in drawing conclusions about which refs or objects are responsible for disk usage\&. The size of a packed non\-delta object may be much larger than the size of objects which delta against it, but the choice of which object is the base and which is the delta is arbitrary and is subject to change during a repack\&.
636 Note also that multiple copies of an object may be present in the object database; in this case, it is undefined which copy\(cqs size or delta base will be reported\&.
639 Part of the \fBgit\fR(1) suite