HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

git ls-tree — List the contents of a tree object. More information: <https://git-scm.com/docs/git-ls-tree>.

Submitted by: @import:tldr-pages··
0
Viewed 0 times
thecommandcontentsgit ls-treetreeobjectclilist

Problem

How to use the git ls-tree command: List the contents of a tree object. More information: <https://git-scm.com/docs/git-ls-tree>.

Solution

git ls-tree — List the contents of a tree object. More information: <https://git-scm.com/docs/git-ls-tree>.

List the contents of the tree on a branch:
git ls-tree {{branch_name}}


List the contents of the tree on a commit, recursing into subtrees:
git ls-tree -r {{commit_hash}}


List only the filenames of the tree on a commit:
git ls-tree --name-only {{commit_hash}}


Print the filenames of the current branch head in a tree structure (Note: tree --fromfile is not supported on Windows):
git ls-tree -r --name-only HEAD | tree --fromfile

Code Snippets

List the contents of the tree on a branch

git ls-tree {{branch_name}}

List the contents of the tree on a commit, recursing into subtrees

git ls-tree -r {{commit_hash}}

List only the filenames of the tree on a commit

git ls-tree --name-only {{commit_hash}}

Print the filenames of the current branch head in a tree structure (Note: `tree --fromfile` is not supported on Windows)

git ls-tree -r --name-only HEAD | tree --fromfile

Context

tldr-pages: common/git ls-tree

Revisions (0)

No revisions yet.