Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | git-ls-tree(1) |
| 2 | ============== |
| 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | 7c73c66 | 2007-01-19 00:37:50 | [diff] [blame] | 6 | git-ls-tree - List the contents of a tree object |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Junio C Hamano | 33db437 | 2006-06-07 19:51:45 | [diff] [blame] | 11 | [verse] |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 12 | 'git ls-tree' [-d] [-r] [-t] [-l] [-z] |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 13 | [--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev[=<n>]] |
| 14 | <tree-ish> [<path>...] |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 15 | |
| 16 | DESCRIPTION |
| 17 | ----------- |
| 18 | Lists the contents of a given tree object, like what "/bin/ls -a" does |
Junio C Hamano | 90ccff3 | 2008-07-29 08:17:24 | [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 |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 22 | '<path>' denotes just a list of patterns to match, e.g. so specifying |
Junio C Hamano | 90ccff3 | 2008-07-29 08:17:24 | [diff] [blame] | 23 | directory name (without '-r') will behave differently, and order of the |
| 24 | arguments does not matter. |
| 25 | |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 26 | - the behaviour is similar to that of "/bin/ls" in that the '<path>' is |
Junio C Hamano | 90ccff3 | 2008-07-29 08:17:24 | [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 |
| 30 | 'sub/dir' in 'HEAD'). You don't want to give a tree that is not at the |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 31 | root level (e.g. `git ls-tree -r HEAD:sub dir`) in this case, as that |
Junio C Hamano | 90ccff3 | 2008-07-29 08:17:24 | [diff] [blame] | 32 | would result in asking for 'sub/sub/dir' in the 'HEAD' commit. |
Junio C Hamano | a3148f5 | 2009-01-14 08:49:57 | [diff] [blame] | 33 | However, the current working directory can be ignored by passing |
| 34 | --full-tree option. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 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 | |
Junio C Hamano | 7fd8417 | 2007-05-24 07:00:32 | [diff] [blame] | 51 | -l:: |
| 52 | --long:: |
| 53 | Show object size of blob (file) entries. |
| 54 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 55 | -z:: |
| 56 | \0 line termination on output. |
| 57 | |
| 58 | --name-only:: |
| 59 | --name-status:: |
| 60 | List only filenames (instead of the "long" output), one per line. |
| 61 | |
Junio C Hamano | 5c3957e | 2006-03-28 00:28:01 | [diff] [blame] | 62 | --abbrev[=<n>]:: |
| 63 | Instead of showing the full 40-byte hexadecimal object |
Junio C Hamano | 6efe302 | 2009-01-13 16:47:56 | [diff] [blame] | 64 | lines, show only a partial prefix. |
Junio C Hamano | 5c3957e | 2006-03-28 00:28:01 | [diff] [blame] | 65 | Non default number of digits can be specified with --abbrev=<n>. |
| 66 | |
Junio C Hamano | 33db437 | 2006-06-07 19:51:45 | [diff] [blame] | 67 | --full-name:: |
Junio C Hamano | f1d1480 | 2006-06-08 00:48:17 | [diff] [blame] | 68 | Instead of showing the path names relative to the current working |
Junio C Hamano | 33db437 | 2006-06-07 19:51:45 | [diff] [blame] | 69 | directory, show the full path names. |
| 70 | |
Junio C Hamano | a3148f5 | 2009-01-14 08:49:57 | [diff] [blame] | 71 | --full-tree:: |
| 72 | Do not limit the listing to the current working directory. |
| 73 | Implies --full-name. |
| 74 | |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 75 | [<path>...]:: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 76 | When paths are given, show them (note that this isn't really raw |
| 77 | pathnames, but rather a list of patterns to match). Otherwise |
| 78 | implicitly uses the root level of the tree as the sole path argument. |
| 79 | |
| 80 | |
| 81 | Output Format |
| 82 | ------------- |
| 83 | <mode> SP <type> SP <object> TAB <file> |
| 84 | |
Junio C Hamano | d4f35a9 | 2009-05-17 05:39:29 | [diff] [blame] | 85 | Unless the `-z` option is used, TAB, LF, and backslash characters |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 86 | in pathnames are represented as `\t`, `\n`, and `\\`, respectively. |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 87 | This output format is compatible with what `--index-info --stdin` of |
Junio C Hamano | d4f35a9 | 2009-05-17 05:39:29 | [diff] [blame] | 88 | 'git update-index' expects. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 89 | |
Junio C Hamano | 7fd8417 | 2007-05-24 07:00:32 | [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 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 98 | GIT |
| 99 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 100 | Part of the linkgit:git[1] suite |