blob: db02d6d79a9c2e092f6c0755300eb2a4579887c0 [file] [log] [blame]
David Greaves2cf565c2005-05-10 22:32:30 +01001git-ls-tree(1)
2==============
David Greaves2cf565c2005-05-10 22:32:30 +01003
4NAME
5----
Junio C Hamanoc3f0baa2007-01-18 15:53:37 -08006git-ls-tree - List the contents of a tree object
David Greaves2cf565c2005-05-10 22:32:30 +01007
8
9SYNOPSIS
10--------
Jonas Fonsecafd7e9fb2006-06-07 21:46:55 +020011[verse]
Jonathan Niederb1889c32008-06-30 01:09:04 -050012'git ls-tree' [-d] [-r] [-t] [-l] [-z]
Štěpán Němec62b46982010-10-08 19:31:15 +020013 [--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev[=<n>]]
14 <tree-ish> [<path>...]
David Greaves2cf565c2005-05-10 22:32:30 +010015
16DESCRIPTION
17-----------
Petr Baudis7b9b4c42005-12-05 00:31:08 +010018Lists the contents of a given tree object, like what "/bin/ls -a" does
Junio C Hamano7ddea132008-07-28 02:33:33 -070019in the current working directory. Note that:
20
21 - the behaviour is slightly different from that of "/bin/ls" in that the
Štěpán Němec62b46982010-10-08 19:31:15 +020022 '<path>' denotes just a list of patterns to match, e.g. so specifying
Matthieu Moy23f82392016-06-28 13:40:10 +020023 directory name (without `-r`) will behave differently, and order of the
Junio C Hamano7ddea132008-07-28 02:33:33 -070024 arguments does not matter.
25
Štěpán Němec62b46982010-10-08 19:31:15 +020026 - the behaviour is similar to that of "/bin/ls" in that the '<path>' is
Junio C Hamano7ddea132008-07-28 02:33:33 -070027 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
Corentin BOMPARD68ed71b2019-03-06 14:04:46 +010030 `sub/dir` in `HEAD`). You don't want to give a tree that is not at the
Thomas Rastca768282010-01-07 17:49:12 +010031 root level (e.g. `git ls-tree -r HEAD:sub dir`) in this case, as that
Corentin BOMPARD68ed71b2019-03-06 14:04:46 +010032 would result in asking for `sub/sub/dir` in the `HEAD` commit.
Nanako Shiraishie1a59772008-12-31 19:00:50 +090033 However, the current working directory can be ignored by passing
34 --full-tree option.
David Greaves2cf565c2005-05-10 22:32:30 +010035
36OPTIONS
37-------
38<tree-ish>::
Johannes Schindelin2c6e4772005-08-05 17:05:02 +020039 Id of a tree-ish.
David Greaves2cf565c2005-05-10 22:32:30 +010040
Junio C Hamano6af1f012005-05-28 00:05:38 -070041-d::
Petr Baudis7b9b4c42005-12-05 00:31:08 +010042 Show only the named tree entry itself, not its children.
Junio C Hamano6af1f012005-05-28 00:05:38 -070043
David Greaves2cf565c2005-05-10 22:32:30 +010044-r::
Petr Baudis7b9b4c42005-12-05 00:31:08 +010045 Recurse into sub-trees.
46
47-t::
48 Show tree entries even when going to recurse them. Has no effect
Matthieu Moy23f82392016-06-28 13:40:10 +020049 if `-r` was not passed. `-d` implies `-t`.
David Greaves2cf565c2005-05-10 22:32:30 +010050
Jakub Narebskia5bbda82007-05-19 22:08:11 +020051-l::
52--long::
53 Show object size of blob (file) entries.
54
David Greaves2cf565c2005-05-10 22:32:30 +010055-z::
Andreas Heiduk860cd692017-03-02 20:03:52 +010056 \0 line termination on output and do not quote filenames.
57 See OUTPUT FORMAT below for more information.
Petr Baudis7b9b4c42005-12-05 00:31:08 +010058
59--name-only::
60--name-status::
61 List only filenames (instead of the "long" output), one per line.
David Greaves2cf565c2005-05-10 22:32:30 +010062
Eric Wongcb85bfe2006-03-07 05:52:02 -080063--abbrev[=<n>]::
64 Instead of showing the full 40-byte hexadecimal object
Junio C Hamanocda34e02020-11-04 14:01:37 -080065 lines, show the shortest prefix that is at least '<n>'
66 hexdigits long that uniquely refers the object.
Eric Wongcb85bfe2006-03-07 05:52:02 -080067 Non default number of digits can be specified with --abbrev=<n>.
68
Jonas Fonsecafd7e9fb2006-06-07 21:46:55 +020069--full-name::
Junio C Hamano42698222006-06-07 16:29:36 -070070 Instead of showing the path names relative to the current working
Jonas Fonsecafd7e9fb2006-06-07 21:46:55 +020071 directory, show the full path names.
72
Nanako Shiraishie1a59772008-12-31 19:00:50 +090073--full-tree::
74 Do not limit the listing to the current working directory.
75 Implies --full-name.
76
Štěpán Němec62b46982010-10-08 19:31:15 +020077[<path>...]::
Petr Baudis7b9b4c42005-12-05 00:31:08 +010078 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.
Junio C Hamano6af1f012005-05-28 00:05:38 -070081
Jason McMullan6d3a5072005-05-26 10:52:50 -070082
David Greaves2cf565c2005-05-10 22:32:30 +010083Output Format
84-------------
Junio C Hamano6af1f012005-05-28 00:05:38 -070085 <mode> SP <type> SP <object> TAB <file>
David Greaves2cf565c2005-05-10 22:32:30 +010086
Thomas Rastca768282010-01-07 17:49:12 +010087This output format is compatible with what `--index-info --stdin` of
Alex Riesenc98a95e2009-05-10 18:14:49 +020088'git update-index' expects.
Junio C Hamanod88156e2005-10-14 21:56:46 -070089
Jakub Narebskia5bbda82007-05-19 22:08:11 +020090When the `-l` option is used, format changes to
91
92 <mode> SP <type> SP <object> SP <object size> TAB <file>
93
94Object size identified by <object> is given in bytes, and right-justified
95with 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
Andreas Heiduk860cd692017-03-02 20:03:52 +010098Without the `-z` option, pathnames with "unusual" characters are
99quoted as explained for the configuration variable `core.quotePath`
100(see linkgit:git-config[1]). Using `-z` the filename is output
101verbatim and the line is terminated by a NUL byte.
102
David Greaves2cf565c2005-05-10 22:32:30 +0100103GIT
104---
Christian Couder9e1f0a82008-06-06 09:07:32 +0200105Part of the linkgit:git[1] suite