LinuxCommandLibrary

git-ls-tree

TLDR

List tree contents

$ git ls-tree HEAD
copy
List recursively
$ git ls-tree -r HEAD
copy
Show only names
$ git ls-tree --name-only HEAD
copy
List specific directory
$ git ls-tree HEAD [src/]
copy
Show sizes
$ git ls-tree -l HEAD
copy

SYNOPSIS

git ls-tree [options] tree-ish [path]

DESCRIPTION

git ls-tree lists the contents of a tree object. It shows file names, modes, types, and object hashes for a specific commit's directory structure.
The command displays git's internal tree structure. It's useful for scripting and understanding how git stores directory contents. Recursive mode shows all files.
git ls-tree inspects repository tree structure at any commit.

PARAMETERS

TREE-ISH

Tree or commit to list.
PATH
Limit to path.
-r
Recurse into subtrees.
-d
Show only trees.
--name-only
Show only names.
--name-status
Show names and status.
-l, --long
Show object sizes.
--abbrev N
Abbreviate hashes.
--help
Display help information.

CAVEATS

Shows tree at specific commit. Plumbing command for scripts. Output format is machine-readable.

HISTORY

git ls-tree is a core Git plumbing command for examining tree objects, part of git's low-level interface.

SEE ALSO

Copied to clipboard