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.36.1.153.gf9b95943b6
10 .TH "GIT\-CAT\-FILE" "1" "05/20/2022" "Git 2\&.36\&.1\&.153\&.gf9b959" "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]
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
72 Exit with zero status if
74 exists and is a valid object\&. If
76 is of an invalid format exit with non\-zero and emits an error on stderr\&.
81 Pretty\-print the contents of
88 Typically this matches the real type of
90 but asking for a type that can trivially be dereferenced from the given
92 is also permitted\&. An example is to ask for a "tree" with
94 being a commit object that contains it, or to ask for a "blob" with
96 being a tag object that points at it\&.
101 Show the content as transformed by a textconv filter\&. In this case,
103 has to be of the form
104 \fB<tree\-ish>:<path>\fR, or
106 in order to apply the filter to the content recorded in the index at
112 Show the content as converted by the filters configured in the current working tree for the given
114 (i\&.e\&. smudge filters, end\-of\-line conversion, etc)\&. In this case,
116 has to be of the form
117 \fB<tree\-ish>:<path>\fR, or
126 \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\&.
129 \-\-batch, \-\-batch=<format>
131 Print object information and contents for each object provided on stdin\&. May not be combined with any other options or arguments except
134 \fB\-\-filters\fR, in which case the input lines also need to specify the path, separated by whitespace\&. See the section
139 \-\-batch\-check, \-\-batch\-check=<format>
141 Print object information for each object provided on stdin\&. May not be combined with any other options or arguments except
144 \fB\-\-filters\fR, in which case the input lines also need to specify the path, separated by whitespace\&. See the section
149 \-\-batch\-command, \-\-batch\-command=<format>
151 Enter a command mode that reads commands and arguments from stdin\&. May only be combined with
155 \fB\-\-filters\fR\&. In the case of
158 \fB\-\-filters\fR, the input lines also need to specify the path, separated by whitespace\&. See the section
162 \fB\-\-batch\-command\fR
163 recognizes the following commands:
167 Print object contents for object reference
168 \fB<object>\fR\&. This corresponds to the output of
174 Print object info for object reference
175 \fB<object>\fR\&. This corresponds to the output of
176 \fB\-\-batch\-check\fR\&.
183 to execute all preceding commands that were issued since the beginning or since the last flush was issued\&. When
185 is used, no output will come until a
189 is not used, commands are flushed each time without issuing
194 \-\-batch\-all\-objects
196 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
199 \fB\-\-batch\-check\fR
200 be specified\&. By default, the objects are visited in order sorted by their hashes; see also
202 below\&. Objects are presented as\-is, without respecting the "replace" mechanism of
203 \fBgit-replace\fR(1)\&.
208 Normally batch output is flushed after each object is output, so that a process can interactively read and write from
209 \fBcat\-file\fR\&. With this option, the output uses normal stdio buffering; this is much more efficient when invoking
210 \fB\-\-batch\-check\fR
212 \fB\-\-batch\-command\fR
213 on a large number of objects\&.
219 \fB\-\-batch\-all\-objects\fR
220 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
221 \fB\-\-batch\fR\&. Note that
223 will still show each object only once, even if it is stored multiple times in the repository\&.
226 \-\-allow\-unknown\-type
232 to query broken/corrupt objects of unknown type\&.
240 \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
242 or a root\-level link to
243 \fB\&.\&./foo\fR), the portion of the link which is outside the tree will be printed\&.
245 This option does not (currently) work correctly when an object in the index is specified (e\&.g\&.
248 \fBHEAD:link\fR) rather than one in the tree\&.
250 This option cannot (currently) be used unless
253 \fB\-\-batch\-check\fR
256 For example, consider a git repository containing:
262 f: a file containing "hello\en"
264 dir/link: a symlink to \&.\&./f
265 plink: a symlink to \&.\&./f
266 alink: a symlink to /etc/passwd
274 \fBecho HEAD:f | git cat\-file \-\-batch\fR
281 ce013625030ba8dba906f756967f9e9ca394464a blob 6
288 \fBecho HEAD:link | git cat\-file \-\-batch \-\-follow\-symlinks\fR
289 would print the same thing, as would
290 \fBHEAD:dir/link\fR, as they both point at
294 \fB\-\-follow\-symlinks\fR, these would print data about the symlink itself\&. In the case of
295 \fBHEAD:link\fR, you would see
301 4d1ae35ba2c8ec712fa2a379db44ad639ca277bd blob 1
311 point outside the tree, so they would respectively print:
337 If \fB\-t\fR is specified, one of the \fB<type>\fR\&.
339 If \fB\-s\fR is specified, the size of the \fB<object>\fR in bytes\&.
341 If \fB\-e\fR is specified, no output, unless the \fB<object>\fR is malformed\&.
343 If \fB\-p\fR is specified, the contents of \fB<object>\fR are pretty\-printed\&.
345 If \fB<type>\fR is specified, the raw (though uncompressed) contents of the \fB<object>\fR will be returned\&.
348 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)\&.
350 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\&.
352 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:
356 The full hex representation of the object name\&.
361 The type of the object (the same as
368 The size, in bytes, of the object (the same as
373 \fBobjectsize:disk\fR
375 The size, in bytes, that the object takes up on disk\&. See the note about on\-disk sizes in the
382 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
389 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
394 If no format is specified, the default format is \fB%(objectname) %(objecttype) %(objectsize)\fR\&.
396 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\&.
398 For example, \fB\-\-batch\fR without a custom format would produce:
404 <oid> SP <type> SP <size> LF
412 Whereas \fB\-\-batch\-check=\(aq%(objectname) %(objecttype)\(aq\fR would produce:
425 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:
431 <object> SP missing LF
438 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:
444 <object> SP ambiguous LF
451 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:
465 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\&.
467 If \fB\-\-follow\-symlinks\fR is used, the following error messages will be displayed:
473 <object> SP missing LF
480 is printed when the initial symlink requested does not exist\&.
486 dangling SP <size> LF
494 is printed when the initial symlink exists, but something that it (transitive\-of) points to does not\&.
508 is printed for symlink loops (or any symlinks that require more than 40 link resolutions to resolve)\&.
522 is printed when, during symlink resolution, a file is used as a directory name\&.
525 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\&.
527 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\&.
530 Part of the \fBgit\fR(1) suite