]> git.ipfire.org Git - thirdparty/git.git/blob - Documentation/git-ls-tree.txt
Merge branch 'jk/rev-list-disk-usage'
[thirdparty/git.git] / Documentation / git-ls-tree.txt
1 git-ls-tree(1)
2 ==============
3
4 NAME
5 ----
6 git-ls-tree - List the contents of a tree object
7
8
9 SYNOPSIS
10 --------
11 [verse]
12 'git ls-tree' [-d] [-r] [-t] [-l] [-z]
13 [--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev[=<n>]]
14 <tree-ish> [<path>...]
15
16 DESCRIPTION
17 -----------
18 Lists the contents of a given tree object, like what "/bin/ls -a" does
19 in the current working directory. Note that:
20
21 - the behaviour is slightly different from that of "/bin/ls" in that the
22 '<path>' denotes just a list of patterns to match, e.g. so specifying
23 directory name (without `-r`) will behave differently, and order of the
24 arguments does not matter.
25
26 - the behaviour is similar to that of "/bin/ls" in that the '<path>' is
27 taken as relative to the current working directory. E.g. when you are
28 in a directory 'sub' that has a directory 'dir', you can run 'git
29 ls-tree -r HEAD dir' to list the contents of the tree (that is
30 `sub/dir` in `HEAD`). You don't want to give a tree that is not at the
31 root level (e.g. `git ls-tree -r HEAD:sub dir`) in this case, as that
32 would result in asking for `sub/sub/dir` in the `HEAD` commit.
33 However, the current working directory can be ignored by passing
34 --full-tree option.
35
36 OPTIONS
37 -------
38 <tree-ish>::
39 Id of a tree-ish.
40
41 -d::
42 Show only the named tree entry itself, not its children.
43
44 -r::
45 Recurse into sub-trees.
46
47 -t::
48 Show tree entries even when going to recurse them. Has no effect
49 if `-r` was not passed. `-d` implies `-t`.
50
51 -l::
52 --long::
53 Show object size of blob (file) entries.
54
55 -z::
56 \0 line termination on output and do not quote filenames.
57 See OUTPUT FORMAT below for more information.
58
59 --name-only::
60 --name-status::
61 List only filenames (instead of the "long" output), one per line.
62
63 --abbrev[=<n>]::
64 Instead of showing the full 40-byte hexadecimal object
65 lines, show the shortest prefix that is at least '<n>'
66 hexdigits long that uniquely refers the object.
67 Non default number of digits can be specified with --abbrev=<n>.
68
69 --full-name::
70 Instead of showing the path names relative to the current working
71 directory, show the full path names.
72
73 --full-tree::
74 Do not limit the listing to the current working directory.
75 Implies --full-name.
76
77 [<path>...]::
78 When paths are given, show them (note that this isn't really raw
79 pathnames, but rather a list of patterns to match). Otherwise
80 implicitly uses the root level of the tree as the sole path argument.
81
82
83 Output Format
84 -------------
85 <mode> SP <type> SP <object> TAB <file>
86
87 This output format is compatible with what `--index-info --stdin` of
88 'git update-index' expects.
89
90 When the `-l` option is used, format changes to
91
92 <mode> SP <type> SP <object> SP <object size> TAB <file>
93
94 Object size identified by <object> is given in bytes, and right-justified
95 with minimum width of 7 characters. Object size is given only for blobs
96 (file) entries; for other entries `-` character is used in place of size.
97
98 Without the `-z` option, pathnames with "unusual" characters are
99 quoted as explained for the configuration variable `core.quotePath`
100 (see linkgit:git-config[1]). Using `-z` the filename is output
101 verbatim and the line is terminated by a NUL byte.
102
103 GIT
104 ---
105 Part of the linkgit:git[1] suite