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.1.440.gcaacdb5dfd
10 .TH "GIT\-LS\-TREE" "1" "2024-12-10" "Git 2\&.47\&.1\&.440\&.gcaacdb" "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\&.
80 \fBdir\fR) in this case, as that would result in asking for
84 commit\&. However, the current working directory can be ignored by passing \-\-full\-tree option\&.
95 Show only the named tree entry itself, not its children\&.
100 Recurse into sub\-trees\&.
105 Show tree entries even when going to recurse them\&. Has no effect if
115 Show object size of blob (file) entries\&.
120 \e0 line termination on output and do not quote filenames\&. See OUTPUT FORMAT below for more information\&.
123 \-\-name\-only, \-\-name\-status
125 List only filenames (instead of the "long" output), one per line\&. Cannot be combined with
126 \fB\-\-object\-only\fR\&.
131 List only names of the objects, one per line\&. Cannot be combined with
134 \fB\-\-name\-status\fR\&. This is equivalent to specifying
135 \fB\-\-format=\fR\*(Aq%(\fBobjectname\fR)\*(Aq, but for both this option and that exact format the command takes a hand\-optimized codepath instead of going through the generic formatting mechanism\&.
140 Instead of showing the full 40\-byte hexadecimal object lines, show the shortest prefix that is at least
142 hexdigits long that uniquely refers the object\&. Non default number of digits can be specified with \-\-abbrev=<n>\&.
147 Instead of showing the path names relative to the current working directory, show the full path names\&.
152 Do not limit the listing to the current working directory\&. Implies \-\-full\-name\&.
157 A string that interpolates %(\fBfieldname\fR) from the result being shown\&. It also interpolates %% to %, and %xNN where
159 are hex digits interpolates to character with hex code
160 \fBNN\fR; for example %x00 interpolates to \e0 (NUL), %x09 to \et (TAB) and %x0a to \en (LF)\&. When specified,
162 cannot be combined with other format\-altering options, including
166 \fB\-\-object\-only\fR\&.
171 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\&.
175 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)\&.
177 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\&.
179 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:
185 %(objectmode) %(objecttype) %(objectname)%x09%(path)
191 This output format is compatible with what \fB\-\-index\-info\fR \fB\-\-stdin\fR of \fIgit update\-index\fR expects\&.
193 When the \fB\-l\fR option is used, format changes to
199 %(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path)
205 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\&.
207 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\&.
211 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 %(\fBfieldname\fR) notation\&. For example, if you only care about the "objectname" and "path" fields, you can execute with a specific "\-\-format" like
217 git ls\-tree \-\-format=\*(Aq%(objectname) %(path)\*(Aq <tree\-ish>
224 Various values from structured fields can be used to interpolate into the resulting output\&. For each outputting line, the following names can be used:
228 The mode of the object\&.
233 The type of the object (\fBcommit\fR,
241 The name of the object\&.
248 object ("\-" if it\(cqs a
251 \fBtree\fR)\&. It also supports a padded format of size with "%(objectsize:padded)"\&.
256 The pathname of the object\&.
260 Part of the \fBgit\fR(1) suite