3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
7 .\" Source: Git 2.42.0.rc0
10 .TH "GIT\-LS\-TREE" "1" "2023\-08\-04" "Git 2\&.42\&.0\&.rc0" "Git Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 git-ls-tree \- List the contents of a tree object
35 \fIgit ls\-tree\fR [\-d] [\-r] [\-t] [\-l] [\-z]
36 [\-\-name\-only] [\-\-name\-status] [\-\-object\-only] [\-\-full\-name] [\-\-full\-tree] [\-\-abbrev[=<n>]] [\-\-format=<format>]
37 <tree\-ish> [<path>\&...]
42 Lists the contents of a given tree object, like what "/bin/ls \-a" does in the current working directory\&. Note that:
52 the behaviour is slightly different from that of "/bin/ls" in that the
54 denotes just a list of patterns to match, e\&.g\&. so specifying directory name (without
55 \fB\-r\fR) will behave differently, and order of the arguments does not matter\&.
66 the behaviour is similar to that of "/bin/ls" in that the
68 is taken as relative to the current working directory\&. E\&.g\&. when you are in a directory
71 \fIdir\fR, you can run
72 \fIgit ls\-tree \-r HEAD dir\fR
73 to list the contents of the tree (that is
76 \fBHEAD\fR)\&. You don\(cqt want to give a tree that is not at the root level (e\&.g\&.
77 \fBgit ls\-tree \-r HEAD:sub dir\fR) in this case, as that would result in asking for
81 commit\&. However, the current working directory can be ignored by passing \-\-full\-tree option\&.
92 Show only the named tree entry itself, not its children\&.
97 Recurse into sub\-trees\&.
102 Show tree entries even when going to recurse them\&. Has no effect if
112 Show object size of blob (file) entries\&.
117 \e0 line termination on output and do not quote filenames\&. See OUTPUT FORMAT below for more information\&.
120 \-\-name\-only, \-\-name\-status
122 List only filenames (instead of the "long" output), one per line\&. Cannot be combined with
123 \fB\-\-object\-only\fR\&.
128 List only names of the objects, one per line\&. Cannot be combined with
131 \fB\-\-name\-status\fR\&. This is equivalent to specifying
132 \fB\-\-format=\*(Aq%(objectname)\*(Aq\fR, but for both this option and that exact format the command takes a hand\-optimized codepath instead of going through the generic formatting mechanism\&.
137 Instead of showing the full 40\-byte hexadecimal object lines, show the shortest prefix that is at least
139 hexdigits long that uniquely refers the object\&. Non default number of digits can be specified with \-\-abbrev=<n>\&.
144 Instead of showing the path names relative to the current working directory, show the full path names\&.
149 Do not limit the listing to the current working directory\&. Implies \-\-full\-name\&.
154 A string that interpolates
156 from the result being shown\&. It also interpolates
163 are hex digits interpolates to character with hex code
164 \fBNN\fR; for example
176 (LF)\&. When specified,
178 cannot be combined with other format\-altering options, including
182 \fB\-\-object\-only\fR\&.
187 When paths are given, show them (note that this isn\(cqt really raw pathnames, but rather a list of patterns to match)\&. Otherwise implicitly uses the root level of the tree as the sole path argument\&.
191 The output format of \fBls\-tree\fR is determined by either the \fB\-\-format\fR option, or other format\-altering options such as \fB\-\-name\-only\fR etc\&. (see \fB\-\-format\fR above)\&.
193 The use of certain \fB\-\-format\fR directives is equivalent to using those options, but invoking the full formatting machinery can be slower than using an appropriate formatting option\&.
195 In cases where the \fB\-\-format\fR would exactly map to an existing option \fBls\-tree\fR will use the appropriate faster path\&. Thus the default format is equivalent to:
201 %(objectmode) %(objecttype) %(objectname)%x09%(path)
207 This output format is compatible with what \fB\-\-index\-info \-\-stdin\fR of \fIgit update\-index\fR expects\&.
209 When the \fB\-l\fR option is used, format changes to
215 %(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path)
221 Object size identified by <objectname> is given in bytes, and right\-justified with minimum width of 7 characters\&. Object size is given only for blobs (file) entries; for other entries \fB\-\fR character is used in place of size\&.
223 Without the \fB\-z\fR option, pathnames with "unusual" characters are quoted as explained for the configuration variable \fBcore\&.quotePath\fR (see \fBgit-config\fR(1))\&. Using \fB\-z\fR the filename is output verbatim and the line is terminated by a NUL byte\&.
227 It is possible to print in a custom format by using the \fB\-\-format\fR option, which is able to interpolate different fields using a \fB%(fieldname)\fR notation\&. For example, if you only care about the "objectname" and "path" fields, you can execute with a specific "\-\-format" like
233 git ls\-tree \-\-format=\*(Aq%(objectname) %(path)\*(Aq <tree\-ish>
240 Various values from structured fields can be used to interpolate into the resulting output\&. For each outputting line, the following names can be used:
244 The mode of the object\&.
249 The type of the object (\fBcommit\fR,
257 The name of the object\&.
264 object ("\-" if it\(cqs a
267 \fBtree\fR)\&. It also supports a padded format of size with "%(objectsize:padded)"\&.
272 The pathname of the object\&.
276 Part of the \fBgit\fR(1) suite