CINXE.COM

Git - git-show-ref 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-show-ref 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-show-ref</strong> manual</header> <ol class='reference-previous-versions'> <li> <a href="/docs/git-show-ref"><span class="version">English</span> </a> </li> <li> <a href="/docs/git-show-ref/pt_BR"><span class="version">Português (Brasil)</span> </a> </li> <li> <a href="/docs/git-show-ref/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-show-ref last updated in 2.46.0</span> <div class='dropdown-panel left' id='previous-versions-dropdown'> <header>Changes in the <strong>git-show-ref</strong> manual</header> <ol class='reference-previous-versions'> <li class="no-change"><span>2.46.1 &rarr; 2.49.0 no changes</span></li> <li> <a href="/docs/git-show-ref/2.46.0"><span class="version">2.46.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">2024-07-29</em> </a> </li> <li class="no-change"><span>2.43.1 &rarr; 2.45.3 no changes</span></li> <li> <a href="/docs/git-show-ref/2.43.0"><span class="version">2.43.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/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2023-11-20</em> </a> </li> <li class="no-change"><span>2.42.1 &rarr; 2.42.4 no changes</span></li> <li> <a href="/docs/git-show-ref/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/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/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2023-08-21</em> </a> </li> <li class="no-change"><span>2.39.1 &rarr; 2.41.3 no changes</span></li> <li> <a href="/docs/git-show-ref/2.39.0"><span class="version">2.39.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">2022-12-12</em> </a> </li> <li class="no-change"><span>2.21.1 &rarr; 2.38.5 no changes</span></li> <li> <a href="/docs/git-show-ref/2.21.0"><span class="version">2.21.0</span> <span class="diff"> <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" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2019-02-24</em> </a> </li> <li class="no-change"><span>2.18.1 &rarr; 2.20.5 no changes</span></li> <li> <a href="/docs/git-show-ref/2.18.0"><span class="version">2.18.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">2018-06-21</em> </a> </li> <li class="no-change"><span>2.10.5 &rarr; 2.17.6 no changes</span></li> <li> <a href="/docs/git-show-ref/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/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">2017-07-30</em> </a> </li> <li class="no-change"><span>2.7.6 &rarr; 2.8.6 no changes</span></li> <li> <a href="/docs/git-show-ref/2.6.7"><span class="version">2.6.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/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2017-05-05</em> </a> </li> <li class="no-change"><span>2.1.4 &rarr; 2.5.6 no changes</span></li> <li> <a href="/docs/git-show-ref/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">2014-12-17</em> </a> </li> <li>&nbsp;</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-show-ref - List references in a local repository</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 show-ref</em> [--head] [-d | --dereference] [-s | --hash[=&lt;n&gt;]] [--abbrev[=&lt;n&gt;]] [--branches] [--tags] [--] [&lt;pattern&gt;&#8230;&#8203;] <em>git show-ref</em> --verify [-q | --quiet] [-d | --dereference] [-s | --hash[=&lt;n&gt;]] [--abbrev[=&lt;n&gt;]] [--] [&lt;ref&gt;&#8230;&#8203;] <em>git show-ref</em> --exclude-existing[=&lt;pattern&gt;] <em>git show-ref</em> --exists &lt;ref&gt;</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>Displays references available in a local repository along with the associated commit IDs. Results can be filtered using a pattern and tags can be dereferenced into object IDs. Additionally, it can be used to test whether a particular ref exists.</p> </div> <div class="paragraph"> <p>By default, shows the tags, heads, and remote refs.</p> </div> <div class="paragraph"> <p>The <code>--exclude-existing</code> form is a filter that does the inverse. It reads refs from stdin, one ref per line, and shows those that don&#8217;t exist in the local repository.</p> </div> <div class="paragraph"> <p>The <code>--exists</code> form can be used to check for the existence of a single references. This form does not verify whether the reference resolves to an actual object.</p> </div> <div class="paragraph"> <p>Use of this utility is encouraged in favor of directly accessing files under the <code>.git</code> directory.</p> </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-show-ref.txt---head"> <a class="anchor" href="#Documentation/git-show-ref.txt---head"></a>--head </dt> <dd> <p>Show the HEAD reference, even if it would normally be filtered out.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt---branches"> <a class="anchor" href="#Documentation/git-show-ref.txt---branches"></a>--branches </dt> <dt class="hdlist1" id="Documentation/git-show-ref.txt---tags"> <a class="anchor" href="#Documentation/git-show-ref.txt---tags"></a>--tags </dt> <dd> <p>Limit to local branches and local tags, respectively. These options are not mutually exclusive; when given both, references stored in "refs/heads" and "refs/tags" are displayed. Note that <code>--heads</code> is a deprecated synonym for <code>--branches</code> and may be removed in the future.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt--d"> <a class="anchor" href="#Documentation/git-show-ref.txt--d"></a>-d </dt> <dt class="hdlist1" id="Documentation/git-show-ref.txt---dereference"> <a class="anchor" href="#Documentation/git-show-ref.txt---dereference"></a>--dereference </dt> <dd> <p>Dereference tags into object IDs as well. They will be shown with <code>^{}</code> appended.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt--s"> <a class="anchor" href="#Documentation/git-show-ref.txt--s"></a>-s </dt> <dt class="hdlist1" id="Documentation/git-show-ref.txt---hashltngt"> <a class="anchor" href="#Documentation/git-show-ref.txt---hashltngt"></a>--hash[=&lt;n&gt;] </dt> <dd> <p>Only show the OID, not the reference name. When combined with <code>--dereference</code>, the dereferenced tag will still be shown after the OID.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt---verify"> <a class="anchor" href="#Documentation/git-show-ref.txt---verify"></a>--verify </dt> <dd> <p>Enable stricter reference checking by requiring an exact ref path. Aside from returning an error code of 1, it will also print an error message if <code>--quiet</code> was not specified.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt---exists"> <a class="anchor" href="#Documentation/git-show-ref.txt---exists"></a>--exists </dt> <dd> <p>Check whether the given reference exists. Returns an exit code of 0 if it does, 2 if it is missing, and 1 in case looking up the reference failed with an error other than the reference being missing.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt---abbrevltngt"> <a class="anchor" href="#Documentation/git-show-ref.txt---abbrevltngt"></a>--abbrev[=&lt;n&gt;] </dt> <dd> <p>Abbreviate the object name. When using <code>--hash</code>, you do not have to say <code>--hash --abbrev</code>; <code>--hash=n</code> would do.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt--q"> <a class="anchor" href="#Documentation/git-show-ref.txt--q"></a>-q </dt> <dt class="hdlist1" id="Documentation/git-show-ref.txt---quiet"> <a class="anchor" href="#Documentation/git-show-ref.txt---quiet"></a>--quiet </dt> <dd> <p>Do not print any results to stdout. Can be used with <code>--verify</code> to silently check if a reference exists.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt---exclude-existingltpatterngt"> <a class="anchor" href="#Documentation/git-show-ref.txt---exclude-existingltpatterngt"></a>--exclude-existing[=&lt;pattern&gt;] </dt> <dd> <p>Make <code>git show-ref</code> act as a filter that reads refs from stdin of the form <code>^(?:&lt;anything&gt;\s)?&lt;refname&gt;(?:\^{})?$</code> and performs the following actions on each: (1) strip <code>^{}</code> at the end of line if any; (2) ignore if pattern is provided and does not head-match refname; (3) warn if refname is not a well-formed refname and skip; (4) ignore if refname is a ref that exists in the local repository; (5) otherwise output the line.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt-ltpatterngt82308203"> <a class="anchor" href="#Documentation/git-show-ref.txt-ltpatterngt82308203"></a>&lt;pattern&gt;&#8230;&#8203; </dt> <dd> <p>Show references matching one or more patterns. Patterns are matched from the end of the full name, and only complete parts are matched, e.g. <em>master</em> matches <em>refs/heads/master</em>, <em>refs/remotes/origin/master</em>, <em>refs/tags/jedi/master</em> but not <em>refs/heads/mymaster</em> or <em>refs/remotes/master/jedi</em>.</p> </dd> </dl> </div> </div> </div> <div class="sect1"> <h2 id="_output"><a class="anchor" href="#_output"></a>OUTPUT</h2> <div class="sectionbody"> <div class="paragraph"> <p>The output is in the format:</p> </div> <div class="listingblock"> <div class="content"> <pre>&lt;oid&gt; SP &lt;ref&gt; LF</pre> </div> </div> <div class="paragraph"> <p>For example,</p> </div> <div class="listingblock"> <div class="content"> <pre>$ git show-ref --head --dereference 832e76a9899f560a90ffd62ae2ce83bbeff58f54 HEAD 832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/master 832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/origin 3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c 6ddc0964034342519a87fe013781abf31c6db6ad refs/tags/v0.99.9c^{} 055e4ae3ae6eb344cbabf2a5256a49ea66040131 refs/tags/v1.0rc4 423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{} ...</pre> </div> </div> <div class="paragraph"> <p>When using <code>--hash</code> (and not <code>--dereference</code>), the output is in the format:</p> </div> <div class="listingblock"> <div class="content"> <pre>&lt;oid&gt; LF</pre> </div> </div> <div class="paragraph"> <p>For example,</p> </div> <div class="listingblock"> <div class="content"> <pre>$ git show-ref --branches --hash 2e3ba0114a1f52b47df29743d6915d056be13278 185008ae97960c8d551adcd9e23565194651b5d1 03adf42c988195b50e1a1935ba5fcbc39b2b029b ...</pre> </div> </div> </div> </div> <div class="sect1"> <h2 id="_examples"><a class="anchor" href="#_examples"></a>EXAMPLES</h2> <div class="sectionbody"> <div class="paragraph"> <p>To show all references called "master", whether tags or heads or anything else, and regardless of how deep in the reference naming hierarchy they are, use:</p> </div> <div class="listingblock"> <div class="content"> <pre> git show-ref master</pre> </div> </div> <div class="paragraph"> <p>This will show "refs/heads/master" but also "refs/remote/other-repo/master", if such references exist.</p> </div> <div class="paragraph"> <p>When using the <code>--verify</code> flag, the command requires an exact path:</p> </div> <div class="listingblock"> <div class="content"> <pre> git show-ref --verify refs/heads/master</pre> </div> </div> <div class="paragraph"> <p>will only match the exact branch called "master".</p> </div> <div class="paragraph"> <p>If nothing matches, <code>git show-ref</code> will return an error code of 1, and in the case of verification, it will show an error message.</p> </div> <div class="paragraph"> <p>For scripting, you can ask it to be quiet with the <code>--quiet</code> flag, which allows you to do things like</p> </div> <div class="listingblock"> <div class="content"> <pre> git show-ref --quiet --verify -- "refs/heads/$headname" || echo "$headname is not a valid branch"</pre> </div> </div> <div class="paragraph"> <p>to check whether a particular branch exists or not (notice how we don&#8217;t actually want to show any results, and we want to use the full refname for it in order to not trigger the problem with ambiguous partial matches).</p> </div> <div class="paragraph"> <p>To show only tags, or only proper branch heads, use <code>--tags</code> and/or <code>--branches</code> respectively (using both means that it shows tags and branches, but not other random references under the refs/ subdirectory).</p> </div> <div class="paragraph"> <p>To do automatic tag object dereferencing, use the <code>-d</code> or <code>--dereference</code> flag, so you can do</p> </div> <div class="listingblock"> <div class="content"> <pre> git show-ref --tags --dereference</pre> </div> </div> <div class="paragraph"> <p>to get a listing of all tags together with what they dereference.</p> </div> </div> </div> <div class="sect1"> <h2 id="_files"><a class="anchor" href="#_files"></a>FILES</h2> <div class="sectionbody"> <div class="paragraph"> <p><code>.git/refs/*</code>, <code>.git/packed-refs</code></p> </div> </div> </div> <div class="sect1"> <h2 id="_see_also"><a class="anchor" href="#_see_also"></a>SEE ALSO</h2> <div class="sectionbody"> <div class="paragraph"> <p><a href='/docs/git-for-each-ref'>git-for-each-ref[1]</a>, <a href='/docs/git-ls-remote'>git-ls-remote[1]</a>, <a href='/docs/git-update-ref'>git-update-ref[1]</a>, <a href='/docs/gitrepository-layout'>gitrepository-layout[5]</a></p> </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">show-ref</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>

Pages: 1 2 3 4 5 6 7 8 9 10