{
    "mode": "man",
    "parameter": "git-ls-tree",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/git-ls-tree/1/json",
    "generated": "2026-06-02T20:22:10Z",
    "synopsis": "git ls-tree [-d] [-r] [-t] [-l] [-z]\n[--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev[=<n>]]\n<tree-ish> [<path>...]",
    "sections": {
        "NAME": {
            "content": "git-ls-tree - List the contents of a tree object\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "git ls-tree [-d] [-r] [-t] [-l] [-z]\n[--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev[=<n>]]\n<tree-ish> [<path>...]\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Lists the contents of a given tree object, like what \"/bin/ls -a\" does in the current working\ndirectory. Note that:\n\n•   the behaviour is slightly different from that of \"/bin/ls\" in that the <path> denotes\njust a list of patterns to match, e.g. so specifying directory name (without -r) will\nbehave differently, and order of the arguments does not matter.\n\n•   the behaviour is similar to that of \"/bin/ls\" in that the <path> is taken as relative to\nthe current working directory. E.g. when you are in a directory sub that has a directory\ndir, you can run git ls-tree -r HEAD dir to list the contents of the tree (that is\nsub/dir in HEAD). You don’t want to give a tree that is not at the root level (e.g.  git\nls-tree -r HEAD:sub dir) in this case, as that would result in asking for sub/sub/dir in\nthe HEAD commit. However, the current working directory can be ignored by passing\n--full-tree option.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "<tree-ish>\nId of a tree-ish.\n",
            "subsections": [
                {
                    "name": "-d",
                    "content": "Show only the named tree entry itself, not its children.\n",
                    "flag": "-d"
                },
                {
                    "name": "-r",
                    "content": "Recurse into sub-trees.\n",
                    "flag": "-r"
                },
                {
                    "name": "-t",
                    "content": "Show tree entries even when going to recurse them. Has no effect if -r was not passed.\n-d implies -t.\n",
                    "flag": "-t"
                },
                {
                    "name": "-l, --long",
                    "content": "Show object size of blob (file) entries.\n",
                    "flag": "-l",
                    "long": "--long"
                },
                {
                    "name": "-z",
                    "content": "\\0 line termination on output and do not quote filenames. See OUTPUT FORMAT below for\nmore information.\n",
                    "flag": "-z"
                },
                {
                    "name": "--name-only, --name-status",
                    "content": "List only filenames (instead of the \"long\" output), one per line.\n\n--abbrev[=<n>]\nInstead of showing the full 40-byte hexadecimal object lines, show the shortest prefix\nthat is at least <n> hexdigits long that uniquely refers the object. Non default number\nof digits can be specified with --abbrev=<n>.\n",
                    "long": "--name-status"
                },
                {
                    "name": "--full-name",
                    "content": "Instead of showing the path names relative to the current working directory, show the\nfull path names.\n",
                    "long": "--full-name"
                },
                {
                    "name": "--full-tree",
                    "content": "Do not limit the listing to the current working directory. Implies --full-name.\n\n[<path>...]\nWhen paths are given, show them (note that this isn’t really raw pathnames, but rather a\nlist of patterns to match). Otherwise implicitly uses the root level of the tree as the\nsole path argument.\n",
                    "long": "--full-tree"
                }
            ]
        },
        "OUTPUT FORMAT": {
            "content": "<mode> SP <type> SP <object> TAB <file>\n\nThis output format is compatible with what --index-info --stdin of git update-index expects.\n\nWhen the -l option is used, format changes to\n\n<mode> SP <type> SP <object> SP <object size> TAB <file>\n\nObject size identified by <object> is given in bytes, and right-justified with minimum width\nof 7 characters. Object size is given only for blobs (file) entries; for other entries -\ncharacter is used in place of size.\n\nWithout the -z option, pathnames with \"unusual\" characters are quoted as explained for the\nconfiguration variable core.quotePath (see git-config(1)). Using -z the filename is output\nverbatim and the line is terminated by a NUL byte.\n",
            "subsections": []
        },
        "GIT": {
            "content": "Part of the git(1) suite\n\n\n\nGit 2.34.1                                   02/26/2026                               GIT-LS-TREE(1)",
            "subsections": []
        }
    },
    "summary": "git-ls-tree - List the contents of a tree object",
    "flags": [
        {
            "flag": "-d",
            "long": null,
            "arg": null,
            "description": "Show only the named tree entry itself, not its children."
        },
        {
            "flag": "-r",
            "long": null,
            "arg": null,
            "description": "Recurse into sub-trees."
        },
        {
            "flag": "-t",
            "long": null,
            "arg": null,
            "description": "Show tree entries even when going to recurse them. Has no effect if -r was not passed. -d implies -t."
        },
        {
            "flag": "-l",
            "long": "--long",
            "arg": null,
            "description": "Show object size of blob (file) entries."
        },
        {
            "flag": "-z",
            "long": null,
            "arg": null,
            "description": "\\0 line termination on output and do not quote filenames. See OUTPUT FORMAT below for more information."
        },
        {
            "flag": "",
            "long": "--name-status",
            "arg": null,
            "description": "List only filenames (instead of the \"long\" output), one per line. --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>."
        },
        {
            "flag": "",
            "long": "--full-name",
            "arg": null,
            "description": "Instead of showing the path names relative to the current working directory, show the full path names."
        },
        {
            "flag": "",
            "long": "--full-tree",
            "arg": null,
            "description": "Do not limit the listing to the current working directory. Implies --full-name. [<path>...] 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."
        }
    ],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "List the contents of a tree object.",
        "examples": [
            {
                "description": "List the contents of the tree on a branch",
                "command": "git ls-tree {{branch_name}}"
            },
            {
                "description": "List the contents of the tree on a commit, recursing into subtrees",
                "command": "git ls-tree -r {{commit_hash}}"
            },
            {
                "description": "List only the filenames of the tree on a commit",
                "command": "git ls-tree --name-only {{commit_hash}}"
            },
            {
                "description": "Print the filenames of the current branch head in a tree structure (Note: `tree --fromfile` is not supported on Windows)",
                "command": "git ls-tree -r --name-only HEAD | tree --fromfile"
            }
        ]
    }
}