6 git-cat-file - Provide content or type and size information for repository objects
12 'git cat-file' <type> <object>
13 'git cat-file' (-e | -p) <object>
14 'git cat-file' (-t | -s) [--allow-unknown-type] <object>
15 'git cat-file' (--batch | --batch-check) [--batch-all-objects]
16 [--buffer] [--follow-symlinks] [--unordered]
17 [--textconv | --filters]
18 'git cat-file' (--textconv | --filters)
19 [<rev>:<path|tree-ish> | --path=<path|tree-ish> <rev>]
23 In its first form, the command provides the content or the type of an object in
24 the repository. The type is required unless `-t` or `-p` is used to find the
25 object type, or `-s` is used to find the object size, or `--textconv` or
26 `--filters` is used (which imply type "blob").
28 In the second form, a list of objects (separated by linefeeds) is provided on
29 stdin, and the SHA-1, type, and size of each object is printed on stdout. The
30 output format can be overridden using the optional `<format>` argument. If
31 either `--textconv` or `--filters` was specified, the input is expected to
32 list the object names followed by the path name, separated by a single
33 whitespace, so that the appropriate drivers can be determined.
38 The name of the object to show.
39 For a more complete list of ways to spell object names, see
40 the "SPECIFYING REVISIONS" section in linkgit:gitrevisions[7].
43 Instead of the content, show the object type identified by
47 Instead of the content, show the object size identified by
51 Exit with zero status if `<object>` exists and is a valid
52 object. If `<object>` is of an invalid format exit with non-zero and
53 emits an error on stderr.
56 Pretty-print the contents of `<object>` based on its type.
59 Typically this matches the real type of `<object>` but asking
60 for a type that can trivially be dereferenced from the given
61 `<object>` is also permitted. An example is to ask for a
62 "tree" with `<object>` being a commit object that contains it,
63 or to ask for a "blob" with `<object>` being a tag object that
67 Show the content as transformed by a textconv filter. In this case,
68 `<object>` has to be of the form `<tree-ish>:<path>`, or `:<path>` in
69 order to apply the filter to the content recorded in the index at
73 Show the content as converted by the filters configured in
74 the current working tree for the given `<path>` (i.e. smudge filters,
75 end-of-line conversion, etc). In this case, `<object>` has to be of
76 the form `<tree-ish>:<path>`, or `:<path>`.
79 For use with `--textconv` or `--filters`, to allow specifying an object
80 name and a path separately, e.g. when it is difficult to figure out
81 the revision from which the blob came.
85 Print object information and contents for each object provided
86 on stdin. May not be combined with any other options or arguments
87 except `--textconv` or `--filters`, in which case the input lines
88 also need to specify the path, separated by whitespace. See the
89 section `BATCH OUTPUT` below for details.
92 --batch-check=<format>::
93 Print object information for each object provided on stdin. May
94 not be combined with any other options or arguments except
95 `--textconv` or `--filters`, in which case the input lines also
96 need to specify the path, separated by whitespace. See the
97 section `BATCH OUTPUT` below for details.
100 Instead of reading a list of objects on stdin, perform the
101 requested batch operation on all objects in the repository and
102 any alternate object stores (not just reachable objects).
103 Requires `--batch` or `--batch-check` be specified. By default,
104 the objects are visited in order sorted by their hashes; see
105 also `--unordered` below. Objects are presented as-is, without
106 respecting the "replace" mechanism of linkgit:git-replace[1].
109 Normally batch output is flushed after each object is output, so
110 that a process can interactively read and write from
111 `cat-file`. With this option, the output uses normal stdio
112 buffering; this is much more efficient when invoking
113 `--batch-check` on a large number of objects.
116 When `--batch-all-objects` is in use, visit objects in an
117 order which may be more efficient for accessing the object
118 contents than hash order. The exact details of the order are
119 unspecified, but if you do not require a specific order, this
120 should generally result in faster output, especially with
121 `--batch`. Note that `cat-file` will still show each object
122 only once, even if it is stored multiple times in the
125 --allow-unknown-type::
126 Allow `-s` or `-t` to query broken/corrupt objects of unknown type.
129 With `--batch` or `--batch-check`, follow symlinks inside the
130 repository when requesting objects with extended SHA-1
131 expressions of the form tree-ish:path-in-tree. Instead of
132 providing output about the link itself, provide output about
133 the linked-to object. If a symlink points outside the
134 tree-ish (e.g. a link to `/foo` or a root-level link to `../foo`),
135 the portion of the link which is outside the tree will be
138 This option does not (currently) work correctly when an object in the
139 index is specified (e.g. `:link` instead of `HEAD:link`) rather than
142 This option cannot (currently) be used unless `--batch` or
143 `--batch-check` is used.
145 For example, consider a git repository containing:
148 f: a file containing "hello\n"
150 dir/link: a symlink to ../f
151 plink: a symlink to ../f
152 alink: a symlink to /etc/passwd
155 For a regular file `f`, `echo HEAD:f | git cat-file --batch` would print
158 ce013625030ba8dba906f756967f9e9ca394464a blob 6
161 And `echo HEAD:link | git cat-file --batch --follow-symlinks` would
162 print the same thing, as would `HEAD:dir/link`, as they both point at
165 Without `--follow-symlinks`, these would print data about the symlink
166 itself. In the case of `HEAD:link`, you would see
169 4d1ae35ba2c8ec712fa2a379db44ad639ca277bd blob 1
172 Both `plink` and `alink` point outside the tree, so they would
186 If `-t` is specified, one of the `<type>`.
188 If `-s` is specified, the size of the `<object>` in bytes.
190 If `-e` is specified, no output, unless the `<object>` is malformed.
192 If `-p` is specified, the contents of `<object>` are pretty-printed.
194 If `<type>` is specified, the raw (though uncompressed) contents of the `<object>`
200 If `--batch` or `--batch-check` is given, `cat-file` will read objects
201 from stdin, one per line, and print information about them. By default,
202 the whole line is considered as an object, as if it were fed to
203 linkgit:git-rev-parse[1].
205 You can specify the information shown for each object by using a custom
206 `<format>`. The `<format>` is copied literally to stdout for each
207 object, with placeholders of the form `%(atom)` expanded, followed by a
208 newline. The available atoms are:
211 The full hex representation of the object name.
214 The type of the object (the same as `cat-file -t` reports).
217 The size, in bytes, of the object (the same as `cat-file -s`
221 The size, in bytes, that the object takes up on disk. See the
222 note about on-disk sizes in the `CAVEATS` section below.
225 If the object is stored as a delta on-disk, this expands to the
226 full hex representation of the delta base object name.
227 Otherwise, expands to the null OID (all zeroes). See `CAVEATS`
231 If this atom is used in the output string, input lines are split
232 at the first whitespace boundary. All characters before that
233 whitespace are considered to be the object name; characters
234 after that first run of whitespace (i.e., the "rest" of the
235 line) are output in place of the `%(rest)` atom.
237 If no format is specified, the default format is `%(objectname)
238 %(objecttype) %(objectsize)`.
240 If `--batch` is specified, the object information is followed by the
241 object contents (consisting of `%(objectsize)` bytes), followed by a
244 For example, `--batch` without a custom format would produce:
247 <oid> SP <type> SP <size> LF
251 Whereas `--batch-check='%(objectname) %(objecttype)'` would produce:
257 If a name is specified on stdin that cannot be resolved to an object in
258 the repository, then `cat-file` will ignore any custom format and print:
261 <object> SP missing LF
264 If a name is specified that might refer to more than one object (an ambiguous short sha), then `cat-file` will ignore any custom format and print:
267 <object> SP ambiguous LF
270 If `--follow-symlinks` is used, and a symlink in the repository points
271 outside the repository, then `cat-file` will ignore any custom format
279 The symlink will either be absolute (beginning with a `/`), or relative
280 to the tree root. For instance, if dir/link points to `../../foo`, then
281 `<symlink>` will be `../foo`. `<size>` is the size of the symlink in bytes.
283 If `--follow-symlinks` is used, the following error messages will be
287 <object> SP missing LF
289 is printed when the initial symlink requested does not exist.
292 dangling SP <size> LF
295 is printed when the initial symlink exists, but something that
296 it (transitive-of) points to does not.
302 is printed for symlink loops (or any symlinks that
303 require more than 40 link resolutions to resolve).
309 is printed when, during symlink resolution, a file is used as a
315 Note that the sizes of objects on disk are reported accurately, but care
316 should be taken in drawing conclusions about which refs or objects are
317 responsible for disk usage. The size of a packed non-delta object may be
318 much larger than the size of objects which delta against it, but the
319 choice of which object is the base and which is the delta is arbitrary
320 and is subject to change during a repack.
322 Note also that multiple copies of an object may be present in the object
323 database; in this case, it is undefined which copy's size or delta base
328 Part of the linkgit:git[1] suite