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