table of contents
- bookworm 1:2.39.2-1.1
- testing 1:2.45.2-1
- unstable 1:2.45.2-1.2
- experimental 1:2.45.2+next.20240614-1
GIT-LS-TREE(1) | Git Manual | GIT-LS-TREE(1) |
NAME¶
git-ls-tree - List the contents of a tree object
SYNOPSIS¶
git ls-tree [-d] [-r] [-t] [-l] [-z]
[--name-only] [--name-status] [--object-only] [--full-name] [--full-tree] [--abbrev[=<n>]] [--format=<format>]
<tree-ish> [<path>...]
DESCRIPTION¶
Lists the contents of a given tree object, like what "/bin/ls -a" does in the current working directory. Note that:
OPTIONS¶
<tree-ish>
-d
-r
-t
-l, --long
-z
--name-only, --name-status
--object-only
--abbrev[=<n>]
--full-name
--full-tree
--format=<format>
[<path>...]
OUTPUT FORMAT¶
The output format of ls-tree is determined by either the --format option, or other format-altering options such as --name-only etc. (see --format above).
The use of certain --format directives is equivalent to using those options, but invoking the full formatting machinery can be slower than using an appropriate formatting option.
In cases where the --format would exactly map to an existing option ls-tree will use the appropriate faster path. Thus the default format is equivalent to:
%(objectmode) %(objecttype) %(objectname)%x09%(path)
This output format is compatible with what --index-info --stdin of git update-index expects.
When the -l option is used, format changes to
%(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path)
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 - character is used in place of size.
Without the -z option, pathnames with "unusual" characters are quoted as explained for the configuration variable core.quotePath (see git-config(1)). Using -z the filename is output verbatim and the line is terminated by a NUL byte.
Customized format:
It is possible to print in a custom format by using the --format option, which is able to interpolate different fields using a %(fieldname) notation. For example, if you only care about the "objectname" and "path" fields, you can execute with a specific "--format" like
git ls-tree --format='%(objectname) %(path)' <tree-ish>
FIELD NAMES¶
Various values from structured fields can be used to interpolate into the resulting output. For each outputing line, the following names can be used:
objectmode
objecttype
objectname
objectsize[:padded]
path
GIT¶
Part of the git(1) suite
02/28/2023 | Git 2.39.2 |