3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
7 .\" Source: Git 2.47.0.rc0.18.ge9356ba3ea
10 .TH "GIT\-LS\-TREE" "1" "2024-09-30" "Git 2\&.47\&.0\&.rc0\&.18\&.ge" "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>\&...\:]
41 Lists the contents of a given tree object, like what "/bin/ls \-a" does in the current working directory\&. Note that:
51 the behaviour is slightly different from that of "/bin/ls" in that the
53 denotes just a list of patterns to match, e\&.g\&. so specifying directory name (without
54 \fB\-r\fR) will behave differently, and order of the arguments does not matter\&.
65 the behaviour is similar to that of "/bin/ls" in that the
67 is taken as relative to the current working directory\&. E\&.g\&. when you are in a directory
70 \fIdir\fR, you can run
71 \fIgit ls\-tree \-r HEAD dir\fR
72 to list the contents of the tree (that is
75 \fBHEAD\fR)\&. You don\(cqt want to give a tree that is not at the root level (e\&.g\&.
76 \fBgit ls\-tree \-r HEAD:sub dir\fR) in this case, as that would result in asking for
80 commit\&. However, the current working directory can be ignored by passing \-\-full\-tree option\&.
91 Show only the named tree entry itself, not its children\&.
96 Recurse into sub\-trees\&.
101 Show tree entries even when going to recurse them\&. Has no effect if
111 Show object size of blob (file) entries\&.
116 \e0 line termination on output and do not quote filenames\&. See OUTPUT FORMAT below for more information\&.
119 \-\-name\-only, \-\-name\-status
121 List only filenames (instead of the "long" output), one per line\&. Cannot be combined with
122 \fB\-\-object\-only\fR\&.
127 List only names of the objects, one per line\&. Cannot be combined with
130 \fB\-\-name\-status\fR\&. This is equivalent to specifying
131 \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\&.
136 Instead of showing the full 40\-byte hexadecimal object lines, show the shortest prefix that is at least
138 hexdigits long that uniquely refers the object\&. Non default number of digits can be specified with \-\-abbrev=<n>\&.
143 Instead of showing the path names relative to the current working directory, show the full path names\&.
148 Do not limit the listing to the current working directory\&. Implies \-\-full\-name\&.
153 A string that interpolates
155 from the result being shown\&. It also interpolates
162 are hex digits interpolates to character with hex code
163 \fBNN\fR; for example
175 (LF)\&. When specified,
177 cannot be combined with other format\-altering options, including
181 \fB\-\-object\-only\fR\&.
186 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\&.
190 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)\&.
192 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\&.
194 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:
200 %(objectmode) %(objecttype) %(objectname)%x09%(path)
206 This output format is compatible with what \fB\-\-index\-info \-\-stdin\fR of \fIgit update\-index\fR expects\&.
208 When the \fB\-l\fR option is used, format changes to
214 %(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path)
220 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\&.
222 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\&.
226 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
232 git ls\-tree \-\-format=\*(Aq%(objectname) %(path)\*(Aq <tree\-ish>
239 Various values from structured fields can be used to interpolate into the resulting output\&. For each outputting line, the following names can be used:
243 The mode of the object\&.
248 The type of the object (\fBcommit\fR,
256 The name of the object\&.
263 object ("\-" if it\(cqs a
266 \fBtree\fR)\&. It also supports a padded format of size with "%(objectsize:padded)"\&.
271 The pathname of the object\&.
275 Part of the \fBgit\fR(1) suite