1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
\r
4 <article lang="en" id="git-show-ref(1)">
\r
6 <title>git-show-ref(1)</title>
\r
8 <primary>git-show-ref(1)</primary>
\r
11 <simplesect id="_name">
\r
13 <simpara>git-show-ref - List references in a local repository</simpara>
\r
15 <simplesect id="_synopsis">
\r
16 <title>SYNOPSIS</title>
\r
18 <literallayout><emphasis>git show-ref</emphasis> [-q|--quiet] [--verify] [-h|--head] [-d|--dereference]
\r
19 [-s|--hash] [--abbrev] [--tags] [--heads] [--] <pattern>…
\r
20 <emphasis>git show-ref</emphasis> --exclude-existing[=pattern]</literallayout>
\r
23 <simplesect id="_description">
\r
24 <title>DESCRIPTION</title>
\r
25 <simpara>Displays references available in a local repository along with the associated
\r
26 commit IDs. Results can be filtered using a pattern and tags can be
\r
27 dereferenced into object IDs. Additionally, it can be used to test whether a
\r
28 particular ref exists.</simpara>
\r
29 <simpara>The --exclude-existing form is a filter that does the inverse, it shows the
\r
30 refs from stdin that don’t exist in the local repository.</simpara>
\r
31 <simpara>Use of this utility is encouraged in favor of directly accessing files under
\r
32 in the <literal>.git</literal> directory.</simpara>
\r
34 <simplesect id="_options">
\r
35 <title>OPTIONS</title>
\r
46 Show the HEAD reference.
\r
59 Limit to only "refs/heads" and "refs/tags", respectively. These
\r
60 options are not mutually exclusive; when given both, references stored
\r
61 in "refs/heads" and "refs/tags" are displayed.
\r
74 Dereference tags into object IDs as well. They will be shown with "^{}"
\r
88 Only show the SHA1 hash, not the reference name. When also using
\r
89 --dereference the dereferenced tag will still be shown after the SHA1.
\r
99 Enable stricter reference checking by requiring an exact ref path.
\r
100 Aside from returning an error code of 1, it will also print an error
\r
101 message if <emphasis>--quiet</emphasis> was not specified.
\r
114 Abbreviate the object name. When using <literal>--hash</literal>, you do
\r
115 not have to say <literal>--hash --abbrev</literal>; <literal>--hash=len</literal> would do.
\r
128 Do not print any results to stdout. When combined with <emphasis>--verify</emphasis> this
\r
129 can be used to silently check if a reference exists.
\r
138 --exclude-existing=pattern
\r
142 Make <emphasis>git-show-ref</emphasis> act as a filter that reads refs from stdin of the
\r
143 form "<superscript>(?:<anything>\s)?<refname>(?:\</superscript>{})?$" and performs the
\r
144 following actions on each:
\r
145 (1) strip "^{}" at the end of line if any;
\r
146 (2) ignore if pattern is provided and does not head-match refname;
\r
147 (3) warn if refname is not a well-formed refname and skip;
\r
148 (4) ignore if refname is a ref that exists in the local repository;
\r
149 (5) otherwise output the line.
\r
155 <pattern>…
\r
159 Show references matching one or more patterns.
\r
165 <simplesect id="_output">
\r
166 <title>OUTPUT</title>
\r
167 <simpara>The output is in the format: <emphasis><SHA-1 ID></emphasis> <emphasis><space></emphasis> <emphasis><reference name></emphasis>.</simpara>
\r
168 <literallayout>$ git show-ref --head --dereference
\r
169 832e76a9899f560a90ffd62ae2ce83bbeff58f54 HEAD
\r
170 832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/master
\r
171 832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/origin
\r
172 3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c
\r
173 6ddc0964034342519a87fe013781abf31c6db6ad refs/tags/v0.99.9c^{}
\r
174 055e4ae3ae6eb344cbabf2a5256a49ea66040131 refs/tags/v1.0rc4
\r
175 423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{}
\r
176 ...</literallayout>
\r
177 <simpara>When using --hash (and not --dereference) the output format is: <emphasis><SHA-1 ID></emphasis></simpara>
\r
178 <literallayout>$ git show-ref --heads --hash
\r
179 2e3ba0114a1f52b47df29743d6915d056be13278
\r
180 185008ae97960c8d551adcd9e23565194651b5d1
\r
181 03adf42c988195b50e1a1935ba5fcbc39b2b029b
\r
182 ...</literallayout>
\r
184 <simplesect id="_example">
\r
185 <title>EXAMPLE</title>
\r
186 <simpara>To show all references called "master", whether tags or heads or anything
\r
187 else, and regardless of how deep in the reference naming hierarchy they are,
\r
189 <literallayout> git show-ref master</literallayout>
\r
190 <simpara>This will show "refs/heads/master" but also "refs/remote/other-repo/master",
\r
191 if such references exists.</simpara>
\r
192 <simpara>When using the <emphasis>--verify</emphasis> flag, the command requires an exact path:</simpara>
\r
193 <literallayout> git show-ref --verify refs/heads/master</literallayout>
\r
194 <simpara>will only match the exact branch called "master".</simpara>
\r
195 <simpara>If nothing matches, <emphasis>git-show-ref</emphasis> will return an error code of 1,
\r
196 and in the case of verification, it will show an error message.</simpara>
\r
197 <simpara>For scripting, you can ask it to be quiet with the "--quiet" flag, which
\r
198 allows you to do things like</simpara>
\r
199 <literallayout> git show-ref --quiet --verify -- "refs/heads/$headname" ||
\r
200 echo "$headname is not a valid branch"</literallayout>
\r
201 <simpara>to check whether a particular branch exists or not (notice how we don’t
\r
202 actually want to show any results, and we want to use the full refname for it
\r
203 in order to not trigger the problem with ambiguous partial matches).</simpara>
\r
204 <simpara>To show only tags, or only proper branch heads, use "--tags" and/or "--heads"
\r
205 respectively (using both means that it shows tags and heads, but not other
\r
206 random references under the refs/ subdirectory).</simpara>
\r
207 <simpara>To do automatic tag object dereferencing, use the "-d" or "--dereference"
\r
208 flag, so you can do</simpara>
\r
209 <literallayout> git show-ref --tags --dereference</literallayout>
\r
210 <simpara>to get a listing of all tags together with what they dereference.</simpara>
\r
212 <simplesect id="_see_also">
\r
213 <title>SEE ALSO</title>
\r
214 <simpara><xref linkend="git-ls-remote(1)"/></simpara>
\r
216 <simplesect id="_authors">
\r
217 <title>AUTHORS</title>
\r
218 <simpara>Written by Linus Torvalds <<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>>.
\r
219 Man page by Jonas Fonseca <<ulink url="mailto:fonseca@diku.dk">fonseca@diku.dk</ulink>>.</simpara>
\r
221 <simplesect id="_git">
\r
223 <simpara>Part of the <xref linkend="git(1)"/> suite</simpara>
\r