David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 1 | git-ls-tree(1) |
| 2 | ============== |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | c3f0baa | 2007-01-18 15:53:37 -0800 | [diff] [blame] | 6 | git-ls-tree - List the contents of a tree object |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Jonas Fonseca | fd7e9fb | 2006-06-07 21:46:55 +0200 | [diff] [blame] | 11 | [verse] |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 12 | 'git ls-tree' [-d] [-r] [-t] [-l] [-z] |
Štěpán Němec | 62b4698 | 2010-10-08 19:31:15 +0200 | [diff] [blame] | 13 | [--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev[=<n>]] |
| 14 | <tree-ish> [<path>...] |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 15 | |
| 16 | DESCRIPTION |
| 17 | ----------- |
Petr Baudis | 7b9b4c4 | 2005-12-05 00:31:08 +0100 | [diff] [blame] | 18 | Lists the contents of a given tree object, like what "/bin/ls -a" does |
Junio C Hamano | 7ddea13 | 2008-07-28 02:33:33 -0700 | [diff] [blame] | 19 | in 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ěmec | 62b4698 | 2010-10-08 19:31:15 +0200 | [diff] [blame] | 22 | '<path>' denotes just a list of patterns to match, e.g. so specifying |
Matthieu Moy | 23f8239 | 2016-06-28 13:40:10 +0200 | [diff] [blame] | 23 | directory name (without `-r`) will behave differently, and order of the |
Junio C Hamano | 7ddea13 | 2008-07-28 02:33:33 -0700 | [diff] [blame] | 24 | arguments does not matter. |
| 25 | |
Štěpán Němec | 62b4698 | 2010-10-08 19:31:15 +0200 | [diff] [blame] | 26 | - the behaviour is similar to that of "/bin/ls" in that the '<path>' is |
Junio C Hamano | 7ddea13 | 2008-07-28 02:33:33 -0700 | [diff] [blame] | 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 |
Corentin BOMPARD | 68ed71b | 2019-03-06 14:04:46 +0100 | [diff] [blame] | 30 | `sub/dir` in `HEAD`). You don't want to give a tree that is not at the |
Thomas Rast | ca76828 | 2010-01-07 17:49:12 +0100 | [diff] [blame] | 31 | root level (e.g. `git ls-tree -r HEAD:sub dir`) in this case, as that |
Corentin BOMPARD | 68ed71b | 2019-03-06 14:04:46 +0100 | [diff] [blame] | 32 | would result in asking for `sub/sub/dir` in the `HEAD` commit. |
Nanako Shiraishi | e1a5977 | 2008-12-31 19:00:50 +0900 | [diff] [blame] | 33 | However, the current working directory can be ignored by passing |
| 34 | --full-tree option. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 35 | |
| 36 | OPTIONS |
| 37 | ------- |
| 38 | <tree-ish>:: |
Johannes Schindelin | 2c6e477 | 2005-08-05 17:05:02 +0200 | [diff] [blame] | 39 | Id of a tree-ish. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 40 | |
Junio C Hamano | 6af1f01 | 2005-05-28 00:05:38 -0700 | [diff] [blame] | 41 | -d:: |
Petr Baudis | 7b9b4c4 | 2005-12-05 00:31:08 +0100 | [diff] [blame] | 42 | Show only the named tree entry itself, not its children. |
Junio C Hamano | 6af1f01 | 2005-05-28 00:05:38 -0700 | [diff] [blame] | 43 | |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 44 | -r:: |
Petr Baudis | 7b9b4c4 | 2005-12-05 00:31:08 +0100 | [diff] [blame] | 45 | Recurse into sub-trees. |
| 46 | |
| 47 | -t:: |
| 48 | Show tree entries even when going to recurse them. Has no effect |
Matthieu Moy | 23f8239 | 2016-06-28 13:40:10 +0200 | [diff] [blame] | 49 | if `-r` was not passed. `-d` implies `-t`. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 50 | |
Jakub Narebski | a5bbda8 | 2007-05-19 22:08:11 +0200 | [diff] [blame] | 51 | -l:: |
| 52 | --long:: |
| 53 | Show object size of blob (file) entries. |
| 54 | |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 55 | -z:: |
Andreas Heiduk | 860cd69 | 2017-03-02 20:03:52 +0100 | [diff] [blame] | 56 | \0 line termination on output and do not quote filenames. |
| 57 | See OUTPUT FORMAT below for more information. |
Petr Baudis | 7b9b4c4 | 2005-12-05 00:31:08 +0100 | [diff] [blame] | 58 | |
| 59 | --name-only:: |
| 60 | --name-status:: |
| 61 | List only filenames (instead of the "long" output), one per line. |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 62 | |
Eric Wong | cb85bfe | 2006-03-07 05:52:02 -0800 | [diff] [blame] | 63 | --abbrev[=<n>]:: |
| 64 | Instead of showing the full 40-byte hexadecimal object |
Junio C Hamano | cda34e0 | 2020-11-04 14:01:37 -0800 | [diff] [blame] | 65 | lines, show the shortest prefix that is at least '<n>' |
| 66 | hexdigits long that uniquely refers the object. |
Eric Wong | cb85bfe | 2006-03-07 05:52:02 -0800 | [diff] [blame] | 67 | Non default number of digits can be specified with --abbrev=<n>. |
| 68 | |
Jonas Fonseca | fd7e9fb | 2006-06-07 21:46:55 +0200 | [diff] [blame] | 69 | --full-name:: |
Junio C Hamano | 4269822 | 2006-06-07 16:29:36 -0700 | [diff] [blame] | 70 | Instead of showing the path names relative to the current working |
Jonas Fonseca | fd7e9fb | 2006-06-07 21:46:55 +0200 | [diff] [blame] | 71 | directory, show the full path names. |
| 72 | |
Nanako Shiraishi | e1a5977 | 2008-12-31 19:00:50 +0900 | [diff] [blame] | 73 | --full-tree:: |
| 74 | Do not limit the listing to the current working directory. |
| 75 | Implies --full-name. |
| 76 | |
Štěpán Němec | 62b4698 | 2010-10-08 19:31:15 +0200 | [diff] [blame] | 77 | [<path>...]:: |
Petr Baudis | 7b9b4c4 | 2005-12-05 00:31:08 +0100 | [diff] [blame] | 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. |
Junio C Hamano | 6af1f01 | 2005-05-28 00:05:38 -0700 | [diff] [blame] | 81 | |
Jason McMullan | 6d3a507 | 2005-05-26 10:52:50 -0700 | [diff] [blame] | 82 | |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 83 | Output Format |
| 84 | ------------- |
Junio C Hamano | 6af1f01 | 2005-05-28 00:05:38 -0700 | [diff] [blame] | 85 | <mode> SP <type> SP <object> TAB <file> |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 86 | |
Thomas Rast | ca76828 | 2010-01-07 17:49:12 +0100 | [diff] [blame] | 87 | This output format is compatible with what `--index-info --stdin` of |
Alex Riesen | c98a95e | 2009-05-10 18:14:49 +0200 | [diff] [blame] | 88 | 'git update-index' expects. |
Junio C Hamano | d88156e | 2005-10-14 21:56:46 -0700 | [diff] [blame] | 89 | |
Jakub Narebski | a5bbda8 | 2007-05-19 22:08:11 +0200 | [diff] [blame] | 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 | |
Andreas Heiduk | 860cd69 | 2017-03-02 20:03:52 +0100 | [diff] [blame] | 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 | |
David Greaves | 2cf565c | 2005-05-10 22:32:30 +0100 | [diff] [blame] | 103 | GIT |
| 104 | --- |
Christian Couder | 9e1f0a8 | 2008-06-06 09:07:32 +0200 | [diff] [blame] | 105 | Part of the linkgit:git[1] suite |