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