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 --unordered
103 When --batch-all-objects is in use, visit objects in an order which
104 may be more efficient for accessing the object contents than hash
105 order. The exact details of the order are unspecified, but if you
106 do not require a specific order, this should generally result in
107 faster output, especially with --batch. Note that cat-file will
108 still show each object only once, even if it is stored multiple
109 times in the repository.
110
111 --allow-unknown-type
112 Allow -s or -t to query broken/corrupt objects of unknown type.
113
114 --follow-symlinks
115 With --batch or --batch-check, follow symlinks inside the
116 repository when requesting objects with extended SHA-1 expressions
117 of the form tree-ish:path-in-tree. Instead of providing output
118 about the link itself, provide output about the linked-to object.
119 If a symlink points outside the tree-ish (e.g. a link to /foo or a
120 root-level link to ../foo), the portion of the link which is
121 outside the tree will be printed.
122
123 This option does not (currently) work correctly when an object in
124 the index is specified (e.g. :link instead of HEAD:link) rather
125 than one in the tree.
126
127 This option cannot (currently) be used unless --batch or
128 --batch-check is used.
129
130 For example, consider a git repository containing:
131
132 f: a file containing "hello\n"
133 link: a symlink to f
134 dir/link: a symlink to ../f
135 plink: a symlink to ../f
136 alink: a symlink to /etc/passwd
137
138 For a regular file f, echo HEAD:f | git cat-file --batch would
139 print
140
141 ce013625030ba8dba906f756967f9e9ca394464a blob 6
142
143 And echo HEAD:link | git cat-file --batch --follow-symlinks would
144 print the same thing, as would HEAD:dir/link, as they both point at
145 HEAD:f.
146
147 Without --follow-symlinks, these would print data about the symlink
148 itself. In the case of HEAD:link, you would see
149
150 4d1ae35ba2c8ec712fa2a379db44ad639ca277bd blob 1
151
152 Both plink and alink point outside the tree, so they would
153 respectively print:
154
155 symlink 4
156 ../f
157
158 symlink 11
159 /etc/passwd
160
162 If -t is specified, one of the <type>.
163
164 If -s is specified, the size of the <object> in bytes.
165
166 If -e is specified, no output, unless the <object> is malformed.
167
168 If -p is specified, the contents of <object> are pretty-printed.
169
170 If <type> is specified, the raw (though uncompressed) contents of the
171 <object> will be returned.
172
174 If --batch or --batch-check is given, cat-file will read objects from
175 stdin, one per line, and print information about them. By default, the
176 whole line is considered as an object, as if it were fed to git-rev-
177 parse(1).
178
179 You can specify the information shown for each object by using a custom
180 <format>. The <format> is copied literally to stdout for each object,
181 with placeholders of the form %(atom) expanded, followed by a newline.
182 The available atoms are:
183
184 objectname
185 The 40-hex object name of the object.
186
187 objecttype
188 The type of the object (the same as cat-file -t reports).
189
190 objectsize
191 The size, in bytes, of the object (the same as cat-file -s
192 reports).
193
194 objectsize:disk
195 The size, in bytes, that the object takes up on disk. See the note
196 about on-disk sizes in the CAVEATS section below.
197
198 deltabase
199 If the object is stored as a delta on-disk, this expands to the
200 40-hex sha1 of the delta base object. Otherwise, expands to the
201 null sha1 (40 zeroes). See CAVEATS below.
202
203 rest
204 If this atom is used in the output string, input lines are split at
205 the first whitespace boundary. All characters before that
206 whitespace are considered to be the object name; characters after
207 that first run of whitespace (i.e., the "rest" of the line) are
208 output in place of the %(rest) atom.
209
210 If no format is specified, the default format is %(objectname)
211 %(objecttype) %(objectsize).
212
213 If --batch is specified, the object information is followed by the
214 object contents (consisting of %(objectsize) bytes), followed by a
215 newline.
216
217 For example, --batch without a custom format would produce:
218
219 <sha1> SP <type> SP <size> LF
220 <contents> LF
221
222
223 Whereas --batch-check='%(objectname) %(objecttype)' would produce:
224
225 <sha1> SP <type> LF
226
227
228 If a name is specified on stdin that cannot be resolved to an object in
229 the repository, then cat-file will ignore any custom format and print:
230
231 <object> SP missing LF
232
233
234 If --follow-symlinks is used, and a symlink in the repository points
235 outside the repository, then cat-file will ignore any custom format and
236 print:
237
238 symlink SP <size> LF
239 <symlink> LF
240
241
242 The symlink will either be absolute (beginning with a /), or relative
243 to the tree root. For instance, if dir/link points to ../../foo, then
244 <symlink> will be ../foo. <size> is the size of the symlink in bytes.
245
246 If --follow-symlinks is used, the following error messages will be
247 displayed:
248
249 <object> SP missing LF
250
251
252 is printed when the initial symlink requested does not exist.
253
254 dangling SP <size> LF
255 <object> LF
256
257
258 is printed when the initial symlink exists, but something that it
259 (transitive-of) points to does not.
260
261 loop SP <size> LF
262 <object> LF
263
264
265 is printed for symlink loops (or any symlinks that require more than 40
266 link resolutions to resolve).
267
268 notdir SP <size> LF
269 <object> LF
270
271
272 is printed when, during symlink resolution, a file is used as a
273 directory name.
274
276 Note that the sizes of objects on disk are reported accurately, but
277 care should be taken in drawing conclusions about which refs or objects
278 are responsible for disk usage. The size of a packed non-delta object
279 may be much larger than the size of objects which delta against it, but
280 the choice of which object is the base and which is the delta is
281 arbitrary and is subject to change during a repack.
282
283 Note also that multiple copies of an object may be present in the
284 object database; in this case, it is undefined which copy’s size or
285 delta base will be reported.
286
288 Part of the git(1) suite
289
290
291
292Git 2.20.1 12/15/2018 GIT-CAT-FILE(1)