1GIT-CAT-FILE(1)                   Git Manual                   GIT-CAT-FILE(1)
2
3
4

NAME

6       git-cat-file - Provide contents or details of repository objects
7

SYNOPSIS

9       git cat-file <type> <object>
10       git cat-file (-e | -p) <object>
11       git cat-file (-t | -s) [--allow-unknown-type] <object>
12       git cat-file (--textconv | --filters)
13                    [<rev>:<path|tree-ish> | --path=<path|tree-ish> <rev>]
14       git cat-file (--batch | --batch-check | --batch-command) [--batch-all-objects]
15                    [--buffer] [--follow-symlinks] [--unordered]
16                    [--textconv | --filters] [-Z]
17

DESCRIPTION

19       Output the contents or other properties such as size, type or delta
20       information of one or more objects.
21
22       This command can operate in two modes, depending on whether an option
23       from the --batch family is specified.
24
25       In non-batch mode, the command provides information on an object named
26       on the command line.
27
28       In batch mode, arguments are read from standard input.
29

OPTIONS

31       <object>
32           The name of the object to show. For a more complete list of ways to
33           spell object names, see the "SPECIFYING REVISIONS" section in
34           gitrevisions(7).
35
36       -t
37           Instead of the content, show the object type identified by
38           <object>.
39
40       -s
41           Instead of the content, show the object size identified by
42           <object>. If used with --use-mailmap option, will show the size of
43           updated object after replacing idents using the mailmap mechanism.
44
45       -e
46           Exit with zero status if <object> exists and is a valid object. If
47           <object> is of an invalid format, exit with non-zero status and
48           emit an error on stderr.
49
50       -p
51           Pretty-print the contents of <object> based on its type.
52
53       <type>
54           Typically this matches the real type of <object> but asking for a
55           type that can trivially be dereferenced from the given <object> is
56           also permitted. An example is to ask for a "tree" with <object>
57           being a commit object that contains it, or to ask for a "blob" with
58           <object> being a tag object that points at it.
59
60       --[no-]mailmap, --[no-]use-mailmap
61           Use mailmap file to map author, committer and tagger names and
62           email addresses to canonical real names and email addresses. See
63           git-shortlog(1).
64
65       --textconv
66           Show the content as transformed by a textconv filter. In this case,
67           <object> has to be of the form <tree-ish>:<path>, or :<path> in
68           order to apply the filter to the content recorded in the index at
69           <path>.
70
71       --filters
72           Show the content as converted by the filters configured in the
73           current working tree for the given <path> (i.e. smudge filters,
74           end-of-line conversion, etc). In this case, <object> has to be of
75           the form <tree-ish>:<path>, or :<path>.
76
77       --path=<path>
78           For use with --textconv or --filters, to allow specifying an object
79           name and a path separately, e.g. when it is difficult to figure out
80           the revision from which the blob came.
81
82       --batch, --batch=<format>
83           Print object information and contents for each object provided on
84           stdin. May not be combined with any other options or arguments
85           except --textconv, --filters, or --use-mailmap.
86
87           •   When used with --textconv or --filters, the input lines must
88               specify the path, separated by whitespace. See the section
89               BATCH OUTPUT below for details.
90
91           •   When used with --use-mailmap, for commit and tag objects, the
92               contents part of the output shows the identities replaced using
93               the mailmap mechanism, while the information part of the output
94               shows the size of the object as if it actually recorded the
95               replacement identities.
96
97       --batch-check, --batch-check=<format>
98           Print object information for each object provided on stdin. May not
99           be combined with any other options or arguments except --textconv,
100           --filters or --use-mailmap.
101
102           •   When used with --textconv or --filters, the input lines must
103               specify the path, separated by whitespace. See the section
104               BATCH OUTPUT below for details.
105
106           •   When used with --use-mailmap, for commit and tag objects, the
107               printed object information shows the size of the object as if
108               the identities recorded in it were replaced by the mailmap
109               mechanism.
110
111       --batch-command, --batch-command=<format>
112           Enter a command mode that reads commands and arguments from stdin.
113           May only be combined with --buffer, --textconv, --use-mailmap or
114           --filters.
115
116           •   When used with --textconv or --filters, the input lines must
117               specify the path, separated by whitespace. See the section
118               BATCH OUTPUT below for details.
119
120           •   When used with --use-mailmap, for commit and tag objects, the
121               contents command shows the identities replaced using the
122               mailmap mechanism, while the info command shows the size of the
123               object as if it actually recorded the replacement identities.
124
125           --batch-command recognizes the following commands:
126
127           contents <object>
128               Print object contents for object reference <object>. This
129               corresponds to the output of --batch.
130
131           info <object>
132               Print object info for object reference <object>. This
133               corresponds to the output of --batch-check.
134
135           flush
136               Used with --buffer to execute all preceding commands that were
137               issued since the beginning or since the last flush was issued.
138               When --buffer is used, no output will come until a flush is
139               issued. When --buffer is not used, commands are flushed each
140               time without issuing flush.
141
142       --batch-all-objects
143           Instead of reading a list of objects on stdin, perform the
144           requested batch operation on all objects in the repository and any
145           alternate object stores (not just reachable objects). Requires
146           --batch or --batch-check be specified. By default, the objects are
147           visited in order sorted by their hashes; see also --unordered
148           below. Objects are presented as-is, without respecting the
149           "replace" mechanism of git-replace(1).
150
151       --buffer
152           Normally batch output is flushed after each object is output, so
153           that a process can interactively read and write from cat-file. With
154           this option, the output uses normal stdio buffering; this is much
155           more efficient when invoking --batch-check or --batch-command on a
156           large number of objects.
157
158       --unordered
159           When --batch-all-objects is in use, visit objects in an order which
160           may be more efficient for accessing the object contents than hash
161           order. The exact details of the order are unspecified, but if you
162           do not require a specific order, this should generally result in
163           faster output, especially with --batch. Note that cat-file will
164           still show each object only once, even if it is stored multiple
165           times in the repository.
166
167       --allow-unknown-type
168           Allow -s or -t to query broken/corrupt objects of unknown type.
169
170       --follow-symlinks
171           With --batch or --batch-check, follow symlinks inside the
172           repository when requesting objects with extended SHA-1 expressions
173           of the form tree-ish:path-in-tree. Instead of providing output
174           about the link itself, provide output about the linked-to object.
175           If a symlink points outside the tree-ish (e.g. a link to /foo or a
176           root-level link to ../foo), the portion of the link which is
177           outside the tree will be printed.
178
179           This option does not (currently) work correctly when an object in
180           the index is specified (e.g.  :link instead of HEAD:link) rather
181           than one in the tree.
182
183           This option cannot (currently) be used unless --batch or
184           --batch-check is used.
185
186           For example, consider a git repository containing:
187
188               f: a file containing "hello\n"
189               link: a symlink to f
190               dir/link: a symlink to ../f
191               plink: a symlink to ../f
192               alink: a symlink to /etc/passwd
193
194           For a regular file f, echo HEAD:f | git cat-file --batch would
195           print
196
197               ce013625030ba8dba906f756967f9e9ca394464a blob 6
198
199           And echo HEAD:link | git cat-file --batch --follow-symlinks would
200           print the same thing, as would HEAD:dir/link, as they both point at
201           HEAD:f.
202
203           Without --follow-symlinks, these would print data about the symlink
204           itself. In the case of HEAD:link, you would see
205
206               4d1ae35ba2c8ec712fa2a379db44ad639ca277bd blob 1
207
208           Both plink and alink point outside the tree, so they would
209           respectively print:
210
211               symlink 4
212               ../f
213
214               symlink 11
215               /etc/passwd
216
217       -Z
218           Only meaningful with --batch, --batch-check, or --batch-command;
219           input and output is NUL-delimited instead of newline-delimited.
220
221       -z
222           Only meaningful with --batch, --batch-check, or --batch-command;
223           input is NUL-delimited instead of newline-delimited. This option is
224           deprecated in favor of -Z as the output can otherwise be ambiguous.
225

OUTPUT

227       If -t is specified, one of the <type>.
228
229       If -s is specified, the size of the <object> in bytes.
230
231       If -e is specified, no output, unless the <object> is malformed.
232
233       If -p is specified, the contents of <object> are pretty-printed.
234
235       If <type> is specified, the raw (though uncompressed) contents of the
236       <object> will be returned.
237

BATCH OUTPUT

239       If --batch or --batch-check is given, cat-file will read objects from
240       stdin, one per line, and print information about them. By default, the
241       whole line is considered as an object, as if it were fed to git-rev-
242       parse(1).
243
244       When --batch-command is given, cat-file will read commands from stdin,
245       one per line, and print information based on the command given. With
246       --batch-command, the info command followed by an object will print
247       information about the object the same way --batch-check would, and the
248       contents command followed by an object prints contents in the same way
249       --batch would.
250
251       You can specify the information shown for each object by using a custom
252       <format>. The <format> is copied literally to stdout for each object,
253       with placeholders of the form %(atom) expanded, followed by a newline.
254       The available atoms are:
255
256       objectname
257           The full hex representation of the object name.
258
259       objecttype
260           The type of the object (the same as cat-file -t reports).
261
262       objectsize
263           The size, in bytes, of the object (the same as cat-file -s
264           reports).
265
266       objectsize:disk
267           The size, in bytes, that the object takes up on disk. See the note
268           about on-disk sizes in the CAVEATS section below.
269
270       deltabase
271           If the object is stored as a delta on-disk, this expands to the
272           full hex representation of the delta base object name. Otherwise,
273           expands to the null OID (all zeroes). See CAVEATS below.
274
275       rest
276           If this atom is used in the output string, input lines are split at
277           the first whitespace boundary. All characters before that
278           whitespace are considered to be the object name; characters after
279           that first run of whitespace (i.e., the "rest" of the line) are
280           output in place of the %(rest) atom.
281
282       If no format is specified, the default format is %(objectname)
283       %(objecttype) %(objectsize).
284
285       If --batch is specified, or if --batch-command is used with the
286       contents command, the object information is followed by the object
287       contents (consisting of %(objectsize) bytes), followed by a newline.
288
289       For example, --batch without a custom format would produce:
290
291           <oid> SP <type> SP <size> LF
292           <contents> LF
293
294       Whereas --batch-check='%(objectname) %(objecttype)' would produce:
295
296           <oid> SP <type> LF
297
298       If a name is specified on stdin that cannot be resolved to an object in
299       the repository, then cat-file will ignore any custom format and print:
300
301           <object> SP missing LF
302
303       If a name is specified that might refer to more than one object (an
304       ambiguous short sha), then cat-file will ignore any custom format and
305       print:
306
307           <object> SP ambiguous LF
308
309       If --follow-symlinks is used, and a symlink in the repository points
310       outside the repository, then cat-file will ignore any custom format and
311       print:
312
313           symlink SP <size> LF
314           <symlink> LF
315
316       The symlink will either be absolute (beginning with a /), or relative
317       to the tree root. For instance, if dir/link points to ../../foo, then
318       <symlink> will be ../foo. <size> is the size of the symlink in bytes.
319
320       If --follow-symlinks is used, the following error messages will be
321       displayed:
322
323           <object> SP missing LF
324
325       is printed when the initial symlink requested does not exist.
326
327           dangling SP <size> LF
328           <object> LF
329
330       is printed when the initial symlink exists, but something that it
331       (transitive-of) points to does not.
332
333           loop SP <size> LF
334           <object> LF
335
336       is printed for symlink loops (or any symlinks that require more than 40
337       link resolutions to resolve).
338
339           notdir SP <size> LF
340           <object> LF
341
342       is printed when, during symlink resolution, a file is used as a
343       directory name.
344
345       Alternatively, when -Z is passed, the line feeds in any of the above
346       examples are replaced with NUL terminators. This ensures that output
347       will be parsable if the output itself would contain a linefeed and is
348       thus recommended for scripting purposes.
349

CAVEATS

351       Note that the sizes of objects on disk are reported accurately, but
352       care should be taken in drawing conclusions about which refs or objects
353       are responsible for disk usage. The size of a packed non-delta object
354       may be much larger than the size of objects which delta against it, but
355       the choice of which object is the base and which is the delta is
356       arbitrary and is subject to change during a repack.
357
358       Note also that multiple copies of an object may be present in the
359       object database; in this case, it is undefined which copy’s size or
360       delta base will be reported.
361

GIT

363       Part of the git(1) suite
364
365
366
367Git 2.43.0                        11/20/2023                   GIT-CAT-FILE(1)
Impressum