CINXE.COM
Git - git-ls-tree Documentation
<!DOCTYPE html> <html lang="en"> <head> <meta charset='utf-8'> <meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Git - git-ls-tree Documentation</title> <link href="/favicon.ico" rel='shortcut icon' type='image/x-icon'> <link rel="stylesheet" href="/application.min.css"> <script src="/js/modernizr.js"></script> <script src="/js/modernize.js"></script> </head> <body id="documentation"> <div class="inner"> <header> <a href="/"><img src="/images/logo@2x.png" width="110" height="46" alt="Git" /></a> <span id="tagline"></span> <script type="text/javascript"> const taglines = [ "fast-version-control", "everything-is-local", "distributed-even-if-your-workflow-isnt", "local-branching-on-the-cheap", "distributed-is-the-new-centralized" ]; var tagline = taglines[Math.floor(Math.random() * taglines.length)]; document.getElementById('tagline').innerHTML = '--' + tagline; </script> <form id="search" action="/search/results"> <input id="search-text" name="search" placeholder="Type / to search entire site…" autocomplete="off" type="text" /> </form> <div id="search-results"></div> </header> </div> <div class="inner"> <div id="content-wrapper"> <div tabindex="1" class="sidebar-btn"></div> <aside class="sidebar" id="sidebar"> <nav> <ul> <li> <a href="/about">About</a> <ul> </ul> </li> <li> <a href="/doc" class="active">Documentation</a> <ul class="expanded"> <li> <a href="/docs" class="active">Reference</a> </li> <li> <a href="/book">Book</a> </li> <li> <a href="/videos">Videos</a> </li> <li> <a href="/doc/ext">External Links</a> </li> </ul> </li> <li> <a href="/downloads">Downloads</a> <ul > <li> <a href="/downloads/guis">GUI Clients</a> </li> <li> <a href="/downloads/logos">Logos</a> </li> </ul> </li> <li> <a href="/community">Community</a> </li> </ul> </nav> </aside> <div id="content"> <div id='reference-version'> <a class="dropdown-trigger" id="reference-languages-trigger" data-panel-id="l10n-versions-dropdown" href="#"> English ▾</a> <div class='dropdown-panel right' id='l10n-versions-dropdown'> <header>Localized versions of <strong>git-ls-tree</strong> manual</header> <ol class='reference-previous-versions'> <li> <a href="/docs/git-ls-tree"><span class="version">English</span> </a> </li> <li> <a href="/docs/git-ls-tree/pt_BR"><span class="version">Português (Brasil)</span> </a> </li> <li> <a href="/docs/git-ls-tree/zh_HANS-CN"><span class="version">简体中文</span> </a> </li> </ol> <footer> Want to read in your language or fix typos?<br/> <a href="https://github.com/jnavila/git-manpages-l10n">You can help translate this page</a>. </footer> </div> <a class="dropdown-trigger" id="reference-topics-trigger" data-panel-id="topics-dropdown" href="#">Topics ▾</a> <div class='dropdown-panel right' id='topics-dropdown'> <div class='three-column'> <div class='column-left'> <h3 class='setup'>Setup and Config</h3> <ul class='unstyled'> <li> <a href="/docs/git"> git </a> </li> <li> <a href="/docs/git-config"> config </a> </li> <li> <a href="/docs/git-help"> help </a> </li> <li> <a href="/docs/git-bugreport"> bugreport </a> </li> <li> <a href="/doc/credential-helpers"> Credential helpers </a> </li> </ul> <h3 class='projects'>Getting and Creating Projects</h3> <ul class='unstyled'> <li> <a href="/docs/git-init"> init </a> </li> <li> <a href="/docs/git-clone"> clone </a> </li> </ul> <h3 class='snapshotting'>Basic Snapshotting</h3> <ul class='unstyled'> <li> <a href="/docs/git-add"> add </a> </li> <li> <a href="/docs/git-status"> status </a> </li> <li> <a href="/docs/git-diff"> diff </a> </li> <li> <a href="/docs/git-commit"> commit </a> </li> <li> <a href="/docs/git-notes"> notes </a> </li> <li> <a href="/docs/git-restore"> restore </a> </li> <li> <a href="/docs/git-reset"> reset </a> </li> <li> <a href="/docs/git-rm"> rm </a> </li> <li> <a href="/docs/git-mv"> mv </a> </li> </ul> <h3 class='branching'>Branching and Merging</h3> <ul class='unstyled'> <li> <a href="/docs/git-branch"> branch </a> </li> <li> <a href="/docs/git-checkout"> checkout </a> </li> <li> <a href="/docs/git-switch"> switch </a> </li> <li> <a href="/docs/git-merge"> merge </a> </li> <li> <a href="/docs/git-mergetool"> mergetool </a> </li> <li> <a href="/docs/git-log"> log </a> </li> <li> <a href="/docs/git-stash"> stash </a> </li> <li> <a href="/docs/git-tag"> tag </a> </li> <li> <a href="/docs/git-worktree"> worktree </a> </li> </ul> <h3 class='sharing'>Sharing and Updating Projects</h3> <ul class='unstyled'> <li> <a href="/docs/git-fetch"> fetch </a> </li> <li> <a href="/docs/git-pull"> pull </a> </li> <li> <a href="/docs/git-push"> push </a> </li> <li> <a href="/docs/git-remote"> remote </a> </li> <li> <a href="/docs/git-submodule"> submodule </a> </li> </ul> </div> <div class='column-middle'> <h3 class='inspection'>Inspection and Comparison</h3> <ul class='unstyled'> <li> <a href="/docs/git-show"> show </a> </li> <li> <a href="/docs/git-log"> log </a> </li> <li> <a href="/docs/git-diff"> diff </a> </li> <li> <a href="/docs/git-difftool"> difftool </a> </li> <li> <a href="/docs/git-range-diff"> range-diff </a> </li> <li> <a href="/docs/git-shortlog"> shortlog </a> </li> <li> <a href="/docs/git-describe"> describe </a> </li> </ul> <h3 class='patching'>Patching</h3> <ul class='unstyled'> <li> <a href="/docs/git-apply"> apply </a> </li> <li> <a href="/docs/git-cherry-pick"> cherry-pick </a> </li> <li> <a href="/docs/git-diff"> diff </a> </li> <li> <a href="/docs/git-rebase"> rebase </a> </li> <li> <a href="/docs/git-revert"> revert </a> </li> </ul> <h3 class='debugging'>Debugging</h3> <ul class='unstyled'> <li> <a href="/docs/git-bisect"> bisect </a> </li> <li> <a href="/docs/git-blame"> blame </a> </li> <li> <a href="/docs/git-grep"> grep </a> </li> </ul> <h3 class='email'>Email</h3> <ul class='unstyled'> <li> <a href="/docs/git-am"> am </a> </li> <li> <a href="/docs/git-apply"> apply </a> </li> <li> <a href="/docs/git-format-patch"> format-patch </a> </li> <li> <a href="/docs/git-send-email"> send-email </a> </li> <li> <a href="/docs/git-request-pull"> request-pull </a> </li> </ul> <h3 class='external'>External Systems</h3> <ul class='unstyled'> <li> <a href="/docs/git-svn"> svn </a> </li> <li> <a href="/docs/git-fast-import"> fast-import </a> </li> </ul> <h3 class='server-admin'>Server Admin</h3> <ul class='unstyled'> <li> <a href="/docs/git-daemon"> daemon </a> </li> <li> <a href="/docs/git-update-server-info"> update-server-info </a> </li> </ul> </div> <div class='column-right'> <h3 class='guides'>Guides</h3> <ul class='unstyled'> <li> <a href="/docs/gitattributes"> gitattributes </a> </li> <li> <a href="/docs/gitcli"> Command-line interface conventions </a> </li> <li> <a href="/docs/giteveryday"> Everyday Git </a> </li> <li> <a href="/docs/gitfaq"> Frequently Asked Questions (FAQ) </a> </li> <li> <a href="/docs/gitglossary"> Glossary </a> </li> <li> <a href="/docs/githooks"> Hooks </a> </li> <li> <a href="/docs/gitignore"> gitignore </a> </li> <li> <a href="/docs/gitmodules"> gitmodules </a> </li> <li> <a href="/docs/gitrevisions"> Revisions </a> </li> <li> <a href="/docs/gitsubmodules"> Submodules </a> </li> <li> <a href="/docs/gittutorial"> Tutorial </a> </li> <li> <a href="/docs/gitworkflows"> Workflows </a> </li> <li> <a href="/docs/git#_guides"> All guides... </a> </li> </ul> <h3 class='admin'>Administration</h3> <ul class='unstyled'> <li> <a href="/docs/git-clean"> clean </a> </li> <li> <a href="/docs/git-gc"> gc </a> </li> <li> <a href="/docs/git-fsck"> fsck </a> </li> <li> <a href="/docs/git-reflog"> reflog </a> </li> <li> <a href="/docs/git-filter-branch"> filter-branch </a> </li> <li> <a href="/docs/git-instaweb"> instaweb </a> </li> <li> <a href="/docs/git-archive"> archive </a> </li> <li> <a href="/docs/git-bundle"> bundle </a> </li> </ul> <h3 class='plumbing'>Plumbing Commands</h3> <ul class='unstyled'> <li> <a href="/docs/git-cat-file"> cat-file </a> </li> <li> <a href="/docs/git-check-ignore"> check-ignore </a> </li> <li> <a href="/docs/git-checkout-index"> checkout-index </a> </li> <li> <a href="/docs/git-commit-tree"> commit-tree </a> </li> <li> <a href="/docs/git-count-objects"> count-objects </a> </li> <li> <a href="/docs/git-diff-index"> diff-index </a> </li> <li> <a href="/docs/git-for-each-ref"> for-each-ref </a> </li> <li> <a href="/docs/git-hash-object"> hash-object </a> </li> <li> <a href="/docs/git-ls-files"> ls-files </a> </li> <li> <a href="/docs/git-ls-tree"> ls-tree </a> </li> <li> <a href="/docs/git-merge-base"> merge-base </a> </li> <li> <a href="/docs/git-read-tree"> read-tree </a> </li> <li> <a href="/docs/git-rev-list"> rev-list </a> </li> <li> <a href="/docs/git-rev-parse"> rev-parse </a> </li> <li> <a href="/docs/git-show-ref"> show-ref </a> </li> <li> <a href="/docs/git-symbolic-ref"> symbolic-ref </a> </li> <li> <a href="/docs/git-update-index"> update-index </a> </li> <li> <a href="/docs/git-update-ref"> update-ref </a> </li> <li> <a href="/docs/git-verify-pack"> verify-pack </a> </li> <li> <a href="/docs/git-write-tree"> write-tree </a> </li> </ul> </div> </div> </div> <a class="dropdown-trigger" id="reference-versions-trigger" data-panel-id="previous-versions-dropdown" href="#"> Latest version ▾ </a> <span class="light d-flex">git-ls-tree last updated in 2.42.0</span> <div class='dropdown-panel left' id='previous-versions-dropdown'> <header>Changes in the <strong>git-ls-tree</strong> manual</header> <ol class='reference-previous-versions'> <li class="no-change"><span>2.42.1 → 2.47.0 no changes</span></li> <li> <a href="/docs/git-ls-tree/2.42.0"><span class="version">2.42.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">08/21/23</em> </a> </li> <li class="no-change"><span>2.36.1 → 2.41.2 no changes</span></li> <li> <a href="/docs/git-ls-tree/2.36.0"><span class="version">2.36.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">04/18/22</em> </a> </li> <li class="no-change"><span>2.30.1 → 2.35.8 no changes</span></li> <li> <a href="/docs/git-ls-tree/2.30.0"><span class="version">2.30.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">12/27/20</em> </a> </li> <li class="no-change"><span>2.22.1 → 2.29.3 no changes</span></li> <li> <a href="/docs/git-ls-tree/2.22.0"><span class="version">2.22.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">06/07/19</em> </a> </li> <li class="no-change"><span>2.14.6 → 2.21.4 no changes</span></li> <li> <a href="/docs/git-ls-tree/2.13.7"><span class="version">2.13.7</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">05/22/18</em> </a> </li> <li class="no-change"><span>2.10.5 → 2.12.5 no changes</span></li> <li> <a href="/docs/git-ls-tree/2.9.5"><span class="version">2.9.5</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">07/30/17</em> </a> </li> <li class="no-change"><span>2.1.4 → 2.8.6 no changes</span></li> <li> <a href="/docs/git-ls-tree/2.0.5"><span class="version">2.0.5</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">12/17/14</em> </a> </li> <li> </li> </ol> <footer> <p>Check your version of git by running</p> <code class="command">git --version</code> </footer> </div> </div> <div id="main" data-pagefind-filter="category:reference" data-pagefind-meta="category:Reference" data-pagefind-weight="0.05" data-pagefind-body> <div class="sect1"> <h2 id="_name"><a class="anchor" href="#_name"></a>NAME</h2> <div class="sectionbody"> <div class="paragraph"> <p>git-ls-tree - List the contents of a tree object</p> </div> </div> </div> <div class="sect1"> <h2 id="_synopsis"><a class="anchor" href="#_synopsis"></a>SYNOPSIS</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content"><em>git ls-tree</em> [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--object-only] [--full-name] [--full-tree] [--abbrev[=<n>]] [--format=<format>] <tree-ish> [<path>…​]</pre> </div> </div> </div> <div class="sect1"> <h2 id="_description"><a class="anchor" href="#_description"></a>DESCRIPTION</h2> <div class="sectionbody"> <div class="paragraph"> <p>Lists the contents of a given tree object, like what "/bin/ls -a" does in the current working directory. Note that:</p> </div> <div class="ulist"> <ul> <li> <p>the behaviour is slightly different from that of "/bin/ls" in that the <em><path></em> denotes just a list of patterns to match, e.g. so specifying directory name (without <code>-r</code>) will behave differently, and order of the arguments does not matter.</p> </li> <li> <p>the behaviour is similar to that of "/bin/ls" in that the <em><path></em> is taken as relative to the current working directory. E.g. when you are in a directory <em>sub</em> that has a directory <em>dir</em>, you can run <em>git ls-tree -r HEAD dir</em> to list the contents of the tree (that is <code>sub/dir</code> in <code>HEAD</code>). You don’t want to give a tree that is not at the root level (e.g. <code>git ls-tree -r HEAD:sub dir</code>) in this case, as that would result in asking for <code>sub/sub/dir</code> in the <code>HEAD</code> commit. However, the current working directory can be ignored by passing --full-tree option.</p> </li> </ul> </div> </div> </div> <div class="sect1"> <h2 id="_options"><a class="anchor" href="#_options"></a>OPTIONS</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-ls-tree.txt-lttree-ishgt"> <a class="anchor" href="#Documentation/git-ls-tree.txt-lttree-ishgt"></a><tree-ish> </dt> <dd> <p>Id of a tree-ish.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt--d"> <a class="anchor" href="#Documentation/git-ls-tree.txt--d"></a>-d </dt> <dd> <p>Show only the named tree entry itself, not its children.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt--r"> <a class="anchor" href="#Documentation/git-ls-tree.txt--r"></a>-r </dt> <dd> <p>Recurse into sub-trees.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt--t"> <a class="anchor" href="#Documentation/git-ls-tree.txt--t"></a>-t </dt> <dd> <p>Show tree entries even when going to recurse them. Has no effect if <code>-r</code> was not passed. <code>-d</code> implies <code>-t</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt--l"> <a class="anchor" href="#Documentation/git-ls-tree.txt--l"></a>-l </dt> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---long"> <a class="anchor" href="#Documentation/git-ls-tree.txt---long"></a>--long </dt> <dd> <p>Show object size of blob (file) entries.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt--z"> <a class="anchor" href="#Documentation/git-ls-tree.txt--z"></a>-z </dt> <dd> <p>\0 line termination on output and do not quote filenames. See OUTPUT FORMAT below for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---name-only"> <a class="anchor" href="#Documentation/git-ls-tree.txt---name-only"></a>--name-only </dt> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---name-status"> <a class="anchor" href="#Documentation/git-ls-tree.txt---name-status"></a>--name-status </dt> <dd> <p>List only filenames (instead of the "long" output), one per line. Cannot be combined with <code>--object-only</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---object-only"> <a class="anchor" href="#Documentation/git-ls-tree.txt---object-only"></a>--object-only </dt> <dd> <p>List only names of the objects, one per line. Cannot be combined with <code>--name-only</code> or <code>--name-status</code>. This is equivalent to specifying <code>--format='%(objectname)'</code>, but for both this option and that exact format the command takes a hand-optimized codepath instead of going through the generic formatting mechanism.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---abbrevltngt"> <a class="anchor" href="#Documentation/git-ls-tree.txt---abbrevltngt"></a>--abbrev[=<n>] </dt> <dd> <p>Instead of showing the full 40-byte hexadecimal object lines, show the shortest prefix that is at least <em><n></em> hexdigits long that uniquely refers the object. Non default number of digits can be specified with --abbrev=<n>.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---full-name"> <a class="anchor" href="#Documentation/git-ls-tree.txt---full-name"></a>--full-name </dt> <dd> <p>Instead of showing the path names relative to the current working directory, show the full path names.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---full-tree"> <a class="anchor" href="#Documentation/git-ls-tree.txt---full-tree"></a>--full-tree </dt> <dd> <p>Do not limit the listing to the current working directory. Implies --full-name.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---formatltformatgt"> <a class="anchor" href="#Documentation/git-ls-tree.txt---formatltformatgt"></a>--format=<format> </dt> <dd> <p>A string that interpolates <code>%(fieldname)</code> from the result being shown. It also interpolates <code>%%</code> to <code>%</code>, and <code>%xNN</code> where <code>NN</code> are hex digits interpolates to character with hex code <code>NN</code>; for example <code>%x00</code> interpolates to <code>\0</code> (NUL), <code>%x09</code> to <code>\t</code> (TAB) and <code>%x0a</code> to <code>\n</code> (LF). When specified, <code>--format</code> cannot be combined with other format-altering options, including <code>--long</code>, <code>--name-only</code> and <code>--object-only</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt-ltpathgt82308203"> <a class="anchor" href="#Documentation/git-ls-tree.txt-ltpathgt82308203"></a>[<path>…​] </dt> <dd> <p>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.</p> </dd> </dl> </div> </div> </div> <div class="sect1"> <h2 id="_output_format"><a class="anchor" href="#_output_format"></a>Output Format</h2> <div class="sectionbody"> <div class="paragraph"> <p>The output format of <code>ls-tree</code> is determined by either the <code>--format</code> option, or other format-altering options such as <code>--name-only</code> etc. (see <code>--format</code> above).</p> </div> <div class="paragraph"> <p>The use of certain <code>--format</code> directives is equivalent to using those options, but invoking the full formatting machinery can be slower than using an appropriate formatting option.</p> </div> <div class="paragraph"> <p>In cases where the <code>--format</code> would exactly map to an existing option <code>ls-tree</code> will use the appropriate faster path. Thus the default format is equivalent to:</p> </div> <div class="literalblock"> <div class="content"> <pre>%(objectmode) %(objecttype) %(objectname)%x09%(path)</pre> </div> </div> <div class="paragraph"> <p>This output format is compatible with what <code>--index-info --stdin</code> of <em>git update-index</em> expects.</p> </div> <div class="paragraph"> <p>When the <code>-l</code> option is used, format changes to</p> </div> <div class="literalblock"> <div class="content"> <pre>%(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path)</pre> </div> </div> <div class="paragraph"> <p>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 <code>-</code> character is used in place of size.</p> </div> <div class="paragraph"> <p>Without the <code>-z</code> option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href='/docs/git-config'>git-config[1]</a>). Using <code>-z</code> the filename is output verbatim and the line is terminated by a NUL byte.</p> </div> <div class="paragraph"> <p>Customized format:</p> </div> <div class="paragraph"> <p>It is possible to print in a custom format by using the <code>--format</code> option, which is able to interpolate different fields using a <code>%(fieldname)</code> notation. For example, if you only care about the "objectname" and "path" fields, you can execute with a specific "--format" like</p> </div> <div class="literalblock"> <div class="content"> <pre>git ls-tree --format='%(objectname) %(path)' <tree-ish></pre> </div> </div> </div> </div> <div class="sect1"> <h2 id="_field_names"><a class="anchor" href="#_field_names"></a>FIELD NAMES</h2> <div class="sectionbody"> <div class="paragraph"> <p>Various values from structured fields can be used to interpolate into the resulting output. For each outputting line, the following names can be used:</p> </div> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-ls-tree.txt-objectmode"> <a class="anchor" href="#Documentation/git-ls-tree.txt-objectmode"></a>objectmode </dt> <dd> <p>The mode of the object.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt-objecttype"> <a class="anchor" href="#Documentation/git-ls-tree.txt-objecttype"></a>objecttype </dt> <dd> <p>The type of the object (<code>commit</code>, <code>blob</code> or <code>tree</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt-objectname"> <a class="anchor" href="#Documentation/git-ls-tree.txt-objectname"></a>objectname </dt> <dd> <p>The name of the object.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt-objectsizepadded"> <a class="anchor" href="#Documentation/git-ls-tree.txt-objectsizepadded"></a>objectsize[:padded] </dt> <dd> <p>The size of a <code>blob</code> object ("-" if it’s a <code>commit</code> or <code>tree</code>). It also supports a padded format of size with "%(objectsize:padded)".</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt-path"> <a class="anchor" href="#Documentation/git-ls-tree.txt-path"></a>path </dt> <dd> <p>The pathname of the object.</p> </dd> </dl> </div> </div> </div> <div class="sect1"> <h2 id="_git"><a class="anchor" href="#_git"></a>GIT</h2> <div class="sectionbody"> <div class="paragraph"> <p>Part of the <a href='/docs/git'>git[1]</a> suite</p> </div> </div> </div> <h3 hidden="true" data-pagefind-weight="7">ls-tree</h3> </div> </div> </div> <footer> <div class="site-source"> <a href="/site">About this site</a><br> Patches, suggestions, and comments are welcome. </div> <div class="sfc-member"> Git is a member of <a href="/sfc">Software Freedom Conservancy</a> </div> </footer> <a href="#top" class="no-js scrollToTop" id="scrollToTop" data-label="Scroll to top"> <img src="/images/icons/chevron-up@2x.png" width="20" height="20" alt="scroll-to-top"/> </a> <script src="/js/jquery-1.7.1.min.js"></script> <script src="/js/jquery-ui-1.8.18.custom.min.js"></script> <script src="/js/jquery.defaultvalue.js"></script> <script src="/js/session.min.js"></script> <script src="/js/application.min.js"></script> </div> </body> </html>