Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/Documentation/git-ls-tree.adoc # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / Documentation / git-ls-tree.adoc` 166 lines ยท 5551 bytes Raw Blame History 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] [--object-only] [--full-name] [--full-tree] [--abbrev[=]] [--format=] 14 [...] 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 '' 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 '' 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 :: 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 <> below for more information. 58 59 --name-only:: 60 --name-status:: 61 List only filenames (instead of the "long" output), one per line. 62 Cannot be combined with `--object-only`. 63 64 --object-only:: 65 List only names of the objects, one per line. Cannot be combined 66 with `--name-only` or `--name-status`. 67 This is equivalent to specifying `--format='%(objectname)'`, but 68 for both this option and that exact format the command takes a 69 hand-optimized codepath instead of going through the generic 70 formatting mechanism. 71 72 --abbrev[=]:: 73 Instead of showing the full 40-byte hexadecimal object 74 lines, show the shortest prefix that is at least '' 75 hexdigits long that uniquely refers the object. 76 Non default number of digits can be specified with --abbrev=. 77 78 --full-name:: 79 Instead of showing the path names relative to the current working 80 directory, show the full path names. 81 82 --full-tree:: 83 Do not limit the listing to the current working directory. 84 Implies --full-name. 85 86 --format=:: 87 A string that interpolates `%(fieldname)` from the result 88 being shown. It also interpolates `%%` to `%`, and 89 `%xNN` where `NN` are hex digits interpolates to character 90 with hex code `NN`; for example `%x00` interpolates to 91 `\0` (NUL), `%x09` to `\t` (TAB) and `%x0a` to `\n` (LF). 92 When specified, `--format` cannot be combined with other 93 format-altering options, including `--long`, `--name-only` 94 and `--object-only`. 95 96 [...]:: 97 When paths are given, show them (note that this isn't really raw 98 pathnames, but rather a list of patterns to match). Otherwise 99 implicitly uses the root level of the tree as the sole path argument. 100 101 102 [[OUTPUT_FORMAT]] 103 Output Format 104 ------------- 105 106 The output format of `ls-tree` is determined by either the `--format` 107 option, or other format-altering options such as `--name-only` etc. 108 (see `--format` above). 109 110 The use of certain `--format` directives is equivalent to using those 111 options, but invoking the full formatting machinery can be slower than 112 using an appropriate formatting option. 113 114 In cases where the `--format` would exactly map to an existing option 115 `ls-tree` will use the appropriate faster path. Thus the default format 116 is equivalent to: 117 118 %(objectmode) %(objecttype) %(objectname)%x09%(path) 119 120 This output format is compatible with what `--index-info --stdin` of 121 'git update-index' expects. 122 123 When the `-l` option is used, format changes to 124 125 %(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path) 126 127 Object size identified by is given in bytes, and right-justified 128 with minimum width of 7 characters. Object size is given only for blobs 129 (file) entries; for other entries `-` character is used in place of size. 130 131 Without the `-z` option, pathnames with "unusual" characters are 132 quoted as explained for the configuration variable `core.quotePath` 133 (see linkgit:git-config[1]). Using `-z` the filename is output 134 verbatim and the line is terminated by a NUL byte. 135 136 Customized format: 137 138 It is possible to print in a custom format by using the `--format` option, 139 which is able to interpolate different fields using a `%(fieldname)` notation. 140 For example, if you only care about the "objectname" and "path" fields, you 141 can execute with a specific "--format" like 142 143 git ls-tree --format='%(objectname) %(path)' 144 145 FIELD NAMES 146 ----------- 147 148 Various values from structured fields can be used to interpolate 149 into the resulting output. For each outputting line, the following 150 names can be used: 151 152 objectmode:: 153 The mode of the object. 154 objecttype:: 155 The type of the object (`commit`, `blob` or `tree`). 156 objectname:: 157 The name of the object. 158 objectsize[:padded]:: 159 The size of a `blob` object ("-" if it's a `commit` or `tree`). 160 It also supports a padded format of size with "%(objectsize:padded)". 161 path:: 162 The pathname of the object. 163 164 GIT 165 --- 166 Part of the linkgit:git[1] suite