Setup and Config
Getting and Creating Projects
Basic Snapshotting
Branching and Merging
Sharing and Updating Projects
Inspection and Comparison
Patching
Debugging
External Systems
Server Admin
- 2.42.1 → 2.44.0 no changes
- 2.42.0 08/21/23
- 2.36.1 → 2.41.0 no changes
- 2.36.0 04/18/22
- 2.30.1 → 2.35.8 no changes
- 2.30.0 12/27/20
- 2.22.1 → 2.29.3 no changes
- 2.22.0 06/07/19
- 2.14.6 → 2.21.4 no changes
- 2.13.7 05/22/18
- 2.10.5 → 2.12.5 no changes
- 2.9.5 07/30/17
- 2.1.4 → 2.8.6 no changes
- 2.0.5 12/17/14
RESUMO
git ls-tree [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--object-only] [--full-name] [--full-tree] [--abbrev[=<n>]] [--format=<formato>] <tree-ish> [<caminho>…]
DESCRIÇÃO
Lists the contents of a given tree object, like what "/bin/ls -a" does in the current working directory. Note that:
o comportamento é um pouco diferente do "/bin/ls", pois o <caminho> indica apenas uma lista de padrões para serem coincididos, portanto, especificar o nome do diretório (sem
-r
) se comportará de maneira diferente e a ordem dos argumentos não importa.the behaviour is similar to that of "/bin/ls" in that the <path> is taken as relative to the current working directory. E.g. when you are in a directory sub that has a directory dir, you can run git ls-tree -r HEAD dir to list the contents of the tree (that is
sub/dir
inHEAD
). You don’t want to give a tree that is not at the root level (e.g.git ls-tree -r HEAD:sub dir
) in this case, as that would result in asking forsub/sub/dir
in theHEAD
commit. However, the current working directory can be ignored by passing --full-tree option.
OPÇÕES
- <tree-ish>
Id de uma
tree-ish
.- -d
Exibe apenas a entrada da árvore informada em si, não seus herdeiros.
- -r
Recursar nas subárvores.
- -t
Exiba as entradas da árvore mesmo quando for recursá-las. Não tem efeito caso
-r
não tenha sido passado.-d
implica no uso da opção-t
.- -l
- --long
Exibe o tamanho do objeto nas entradas da bolha (arquivo).
- -z
\0 line termination on output and do not quote filenames. See OUTPUT FORMAT below for more information.
- --name-only
- --name-status
List only filenames (instead of the "long" output), one per line. Cannot be combined with
--object-only
.- --object-only
List only names of the objects, one per line. Cannot be combined with
--name-only
or--name-status
. This is equivalent to specifying--format='%(objectname)'
, but for both this option and that exact format the command takes a hand-optimized codepath instead of going through the generic formatting mechanism.- --abbrev[=<n>]
Instead of showing the full 40-byte hexadecimal object lines, show the shortest prefix that is at least <n> hexdigits long that uniquely refers the object. Non default number of digits can be specified with --abbrev=<n>.
- --full-name
Em vez de mostrar os nomes dos caminhos relativos ao diretório de trabalho atual, mostre os nomes completos dos caminhos.
- --full-tree
Do not limit the listing to the current working directory. Implies --full-name.
- --format=<formato>
A string that interpolates
%(fieldname)
from the result being shown. It also interpolates%%
to%
, and%xNN
whereNN
are hex digits interpolates to character with hex codeNN
; for example%x00
interpolates to\0
(NUL),%x09
to\t
(TAB) and%x0a
to\n
(LF). When specified,--format
cannot be combined with other format-altering options, including--long
,--name-only
and--object-only
.- [<caminho>…]
When paths are given, show them (note that this isn’t really raw pathnames, but rather a list of patterns to match). Otherwise implicitly uses the root level of the tree as the sole path argument.
Formato de saída
The output format of ls-tree
is determined by either the --format
option, or other format-altering options such as --name-only
etc. (see --format
above).
O uso de certas diretivas --format
à utilização dessas opções, ao invocar o mecanismo completo de formatação pode ser mais lento do que se usar uma opção de formatação apropriada.
Nos casos onde o --format
mapearia exatamente para uma opção existente, o ls-tree
utilizará o caminho mais rápido e apropriado. Assim, o formato padrão é equivalente a:
%(objectmode) %(objecttype) %(objectname)%x09%(path)
Este formato gerado é compatível com o que a opção --index-info --stdin
do comando git update-index espera.
Quando a opção -l
é utilizada, o formato muda para
%(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path)
Object size identified by <objectname> is given in bytes, and right-justified with minimum width of 7 characters. Object size is given only for blobs (file) entries; for other entries -
character is used in place of size.
Sem a opção z
, os pathnames
com os caracteres "incomuns" são citados conforme explicado na variável de configuração core.quotePath
(consulte git-config[1]). Utilizando a opção -z
, o nome do arquivo é gerado literalmente e a linha é finalizada com um byte NUL
.
Formato personalizado:
É possível imprimir em um formato personalizado usando a opção --format
, que é capaz de interpolar diferentes campos usando uma notação %(fieldname)
. Por exemplo, se você se importa apenas com os campos "objectname" e "path", você pode executar com um comando "--format" específico como
git ls-tree --format='%(objectname) %(caminho)' <tree-ish>
NOME DOS CAMPOS
Vários valores dos campos estruturados podem ser usados para interpolar na saída resultante. Para cada linha gerada, os seguintes nomes podem ser usadas:
GIT
Parte do conjunto git[1]