1GIT-CAT-FILE(1) Git Manual GIT-CAT-FILE(1)
2
3
4
6 git-cat-file - Provide content or type and size information for
7 repository objects
8
10 git cat-file (-t [--allow-unknown-type]| -s [--allow-unknown-type]| -e | -p | <type> | --textconv | --filters ) [--path=<path>] <object>
11 git cat-file (--batch | --batch-check) [ --textconv | --filters ] [--follow-symlinks]
12
13
15 In its first form, the command provides the content or the type of an
16 object in the repository. The type is required unless -t or -p is used
17 to find the object type, or -s is used to find the object size, or
18 --textconv or --filters is used (which imply type "blob").
19
20 In the second form, a list of objects (separated by linefeeds) is
21 provided on stdin, and the SHA-1, type, and size of each object is
22 printed on stdout. The output format can be overridden using the
23 optional <format> argument. If either --textconv or --filters was
24 specified, the input is expected to list the object names followed by
25 the path name, separated by a single white space, so that the
26 appropriate drivers can be determined.
27
29 <object>
30 The name of the object to show. For a more complete list of ways to
31 spell object names, see the "SPECIFYING REVISIONS" section in
32 gitrevisions(7).
33
34 -t
35 Instead of the content, show the object type identified by
36 <object>.
37
38 -s
39 Instead of the content, show the object size identified by
40 <object>.
41
42 -e
43 Exit with zero status if <object> exists and is a valid object. If
44 <object> is of an invalid format exit with non-zero and emits an
45 error on stderr.
46
47 -p
48 Pretty-print the contents of <object> based on its type.
49
50 <type>
51 Typically this matches the real type of <object> but asking for a
52 type that can trivially be dereferenced from the given <object> is
53 also permitted. An example is to ask for a "tree" with <object>
54 being a commit object that contains it, or to ask for a "blob" with
55 <object> being a tag object that points at it.
56
57 --textconv
58 Show the content as transformed by a textconv filter. In this case,
59 <object> has to be of the form <tree-ish>:<path>, or :<path> in
60 order to apply the filter to the content recorded in the index at
61 <path>.
62
63 --filters
64 Show the content as converted by the filters configured in the
65 current working tree for the given <path> (i.e. smudge filters,
66 end-of-line conversion, etc). In this case, <object> has to be of
67 the form <tree-ish>:<path>, or :<path>.
68
69 --path=<path>
70 For use with --textconv or --filters, to allow specifying an object
71 name and a path separately, e.g. when it is difficult to figure out
72 the revision from which the blob came.
73
74 --batch, --batch=<format>
75 Print object information and contents for each object provided on
76 stdin. May not be combined with any other options or arguments
77 except --textconv or --filters, in which case the input lines also
78 need to specify the path, separated by white space. See the section
79 BATCH OUTPUT below for details.
80
81 --batch-check, --batch-check=<format>
82 Print object information for each object provided on stdin. May not
83 be combined with any other options or arguments except --textconv
84 or --filters, in which case the input lines also need to specify
85 the path, separated by white space. See the section BATCH OUTPUT
86 below for details.
87
88 --batch-all-objects
89 Instead of reading a list of objects on stdin, perform the
90 requested batch operation on all objects in the repository and any
91 alternate object stores (not just reachable objects). Requires
92 --batch or --batch-check be specified. Note that the objects are
93 visited in order sorted by their hashes.
94
95 --buffer
96 Normally batch output is flushed after each object is output, so
97 that a process can interactively read and write from cat-file. With
98 this option, the output uses normal stdio buffering; this is much
99 more efficient when invoking --batch-check on a large number of
100 objects.
101
102 --allow-unknown-type
103 Allow -s or -t to query broken/corrupt objects of unknown type.
104
105 --follow-symlinks
106 With --batch or --batch-check, follow symlinks inside the
107 repository when requesting objects with extended SHA-1 expressions
108 of the form tree-ish:path-in-tree. Instead of providing output
109 about the link itself, provide output about the linked-to object.
110 If a symlink points outside the tree-ish (e.g. a link to /foo or a
111 root-level link to ../foo), the portion of the link which is
112 outside the tree will be printed.
113
114 This option does not (currently) work correctly when an object in
115 the index is specified (e.g. :link instead of HEAD:link) rather
116 than one in the tree.
117
118 This option cannot (currently) be used unless --batch or
119 --batch-check is used.
120
121 For example, consider a git repository containing:
122
123 f: a file containing "hello\n"
124 link: a symlink to f
125 dir/link: a symlink to ../f
126 plink: a symlink to ../f
127 alink: a symlink to /etc/passwd
128
129 For a regular file f, echo HEAD:f | git cat-file --batch would
130 print
131
132 ce013625030ba8dba906f756967f9e9ca394464a blob 6
133
134 And echo HEAD:link | git cat-file --batch --follow-symlinks would
135 print the same thing, as would HEAD:dir/link, as they both point at
136 HEAD:f.
137
138 Without --follow-symlinks, these would print data about the symlink
139 itself. In the case of HEAD:link, you would see
140
141 4d1ae35ba2c8ec712fa2a379db44ad639ca277bd blob 1
142
143 Both plink and alink point outside the tree, so they would
144 respectively print:
145
146 symlink 4
147 ../f
148
149 symlink 11
150 /etc/passwd
151
153 If -t is specified, one of the <type>.
154
155 If -s is specified, the size of the <object> in bytes.
156
157 If -e is specified, no output, unless the <object> is malformed.
158
159 If -p is specified, the contents of <object> are pretty-printed.
160
161 If <type> is specified, the raw (though uncompressed) contents of the
162 <object> will be returned.
163
165 If --batch or --batch-check is given, cat-file will read objects from
166 stdin, one per line, and print information about them. By default, the
167 whole line is considered as an object, as if it were fed to git-rev-
168 parse(1).
169
170 You can specify the information shown for each object by using a custom
171 <format>. The <format> is copied literally to stdout for each object,
172 with placeholders of the form %(atom) expanded, followed by a newline.
173 The available atoms are:
174
175 objectname
176 The 40-hex object name of the object.
177
178 objecttype
179 The type of the object (the same as cat-file -t reports).
180
181 objectsize
182 The size, in bytes, of the object (the same as cat-file -s
183 reports).
184
185 objectsize:disk
186 The size, in bytes, that the object takes up on disk. See the note
187 about on-disk sizes in the CAVEATS section below.
188
189 deltabase
190 If the object is stored as a delta on-disk, this expands to the
191 40-hex sha1 of the delta base object. Otherwise, expands to the
192 null sha1 (40 zeroes). See CAVEATS below.
193
194 rest
195 If this atom is used in the output string, input lines are split at
196 the first whitespace boundary. All characters before that
197 whitespace are considered to be the object name; characters after
198 that first run of whitespace (i.e., the "rest" of the line) are
199 output in place of the %(rest) atom.
200
201 If no format is specified, the default format is %(objectname)
202 %(objecttype) %(objectsize).
203
204 If --batch is specified, the object information is followed by the
205 object contents (consisting of %(objectsize) bytes), followed by a
206 newline.
207
208 For example, --batch without a custom format would produce:
209
210 <sha1> SP <type> SP <size> LF
211 <contents> LF
212
213
214 Whereas --batch-check='%(objectname) %(objecttype)' would produce:
215
216 <sha1> SP <type> LF
217
218
219 If a name is specified on stdin that cannot be resolved to an object in
220 the repository, then cat-file will ignore any custom format and print:
221
222 <object> SP missing LF
223
224
225 If --follow-symlinks is used, and a symlink in the repository points
226 outside the repository, then cat-file will ignore any custom format and
227 print:
228
229 symlink SP <size> LF
230 <symlink> LF
231
232
233 The symlink will either be absolute (beginning with a /), or relative
234 to the tree root. For instance, if dir/link points to ../../foo, then
235 <symlink> will be ../foo. <size> is the size of the symlink in bytes.
236
237 If --follow-symlinks is used, the following error messages will be
238 displayed:
239
240 <object> SP missing LF
241
242
243 is printed when the initial symlink requested does not exist.
244
245 dangling SP <size> LF
246 <object> LF
247
248
249 is printed when the initial symlink exists, but something that it
250 (transitive-of) points to does not.
251
252 loop SP <size> LF
253 <object> LF
254
255
256 is printed for symlink loops (or any symlinks that require more than 40
257 link resolutions to resolve).
258
259 notdir SP <size> LF
260 <object> LF
261
262
263 is printed when, during symlink resolution, a file is used as a
264 directory name.
265
267 Note that the sizes of objects on disk are reported accurately, but
268 care should be taken in drawing conclusions about which refs or objects
269 are responsible for disk usage. The size of a packed non-delta object
270 may be much larger than the size of objects which delta against it, but
271 the choice of which object is the base and which is the delta is
272 arbitrary and is subject to change during a repack.
273
274 Note also that multiple copies of an object may be present in the
275 object database; in this case, it is undefined which copy’s size or
276 delta base will be reported.
277
279 Part of the git(1) suite
280
281
282
283Git 2.18.1 05/14/2019 GIT-CAT-FILE(1)