Update git documentation
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / git-show-ref.xml
blob5833799ee7f5406a0b3e6cab8c73cbbf74a494fd
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE sect2 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <sect2 lang="en" id="git-show-ref(1)">\r
5     <title>git-show-ref(1)</title>\r
6 <indexterm>\r
7 <primary>git-show-ref(1)</primary>\r
8 </indexterm>\r
9 <simplesect id="git-show-ref(1)__name">\r
10 <title>NAME</title>\r
11 <simpara>git-show-ref - List references in a local repository</simpara>\r
12 </simplesect>\r
13 <simplesect id="git-show-ref(1)__synopsis">\r
14 <title>SYNOPSIS</title>\r
15 <blockquote>\r
16 <literallayout><emphasis>git show-ref</emphasis> [-q|--quiet] [--verify] [--head] [-d|--dereference]\r
17              [-s|--hash[=&lt;n&gt;]] [--abbrev[=&lt;n&gt;]] [--tags]\r
18              [--heads] [--] [&lt;pattern&gt;&#8230;]\r
19 <emphasis>git show-ref</emphasis> --exclude-existing[=&lt;pattern&gt;]</literallayout>\r
20 </blockquote>\r
21 </simplesect>\r
22 <simplesect id="git-show-ref(1)__description">\r
23 <title>DESCRIPTION</title>\r
24 <simpara>Displays references available in a local repository along with the associated\r
25 commit IDs. Results can be filtered using a pattern and tags can be\r
26 dereferenced into object IDs. Additionally, it can be used to test whether a\r
27 particular ref exists.</simpara>\r
28 <simpara>By default, shows the tags, heads, and remote refs.</simpara>\r
29 <simpara>The --exclude-existing form is a filter that does the inverse. It reads\r
30 refs from stdin, one ref per line, and shows those that don't exist in\r
31 the local repository.</simpara>\r
32 <simpara>Use of this utility is encouraged in favor of directly accessing files under\r
33 the <emphasis>.git</emphasis> directory.</simpara>\r
34 </simplesect>\r
35 <simplesect id="git-show-ref(1)__options">\r
36 <title>OPTIONS</title>\r
37 <variablelist>\r
38 <varlistentry>\r
39 <term>\r
40 --head\r
41 </term>\r
42 <listitem>\r
43 <simpara>\r
44         Show the HEAD reference, even if it would normally be filtered out.\r
45 </simpara>\r
46 </listitem>\r
47 </varlistentry>\r
48 <varlistentry>\r
49 <term>\r
50 --tags\r
51 </term>\r
52 <term>\r
53 --heads\r
54 </term>\r
55 <listitem>\r
56 <simpara>\r
57         Limit to "refs/heads" and "refs/tags", respectively.  These options\r
58         are not mutually exclusive; when given both, references stored in\r
59         "refs/heads" and "refs/tags" are displayed.\r
60 </simpara>\r
61 </listitem>\r
62 </varlistentry>\r
63 <varlistentry>\r
64 <term>\r
65 -d\r
66 </term>\r
67 <term>\r
68 --dereference\r
69 </term>\r
70 <listitem>\r
71 <simpara>\r
72         Dereference tags into object IDs as well. They will be shown with "&#94;{}"\r
73         appended.\r
74 </simpara>\r
75 </listitem>\r
76 </varlistentry>\r
77 <varlistentry>\r
78 <term>\r
79 -s\r
80 </term>\r
81 <term>\r
82 --hash[=&lt;n&gt;]\r
83 </term>\r
84 <listitem>\r
85 <simpara>\r
86         Only show the SHA-1 hash, not the reference name. When combined with\r
87         --dereference the dereferenced tag will still be shown after the SHA-1.\r
88 </simpara>\r
89 </listitem>\r
90 </varlistentry>\r
91 <varlistentry>\r
92 <term>\r
93 --verify\r
94 </term>\r
95 <listitem>\r
96 <simpara>\r
97         Enable stricter reference checking by requiring an exact ref path.\r
98         Aside from returning an error code of 1, it will also print an error\r
99         message if <emphasis>--quiet</emphasis> was not specified.\r
100 </simpara>\r
101 </listitem>\r
102 </varlistentry>\r
103 <varlistentry>\r
104 <term>\r
105 --abbrev[=&lt;n&gt;]\r
106 </term>\r
107 <listitem>\r
108 <simpara>\r
109         Abbreviate the object name.  When using <emphasis>--hash</emphasis>, you do\r
110         not have to say <emphasis>--hash --abbrev</emphasis>; <emphasis>--hash=n</emphasis> would do.\r
111 </simpara>\r
112 </listitem>\r
113 </varlistentry>\r
114 <varlistentry>\r
115 <term>\r
116 -q\r
117 </term>\r
118 <term>\r
119 --quiet\r
120 </term>\r
121 <listitem>\r
122 <simpara>\r
123         Do not print any results to stdout. When combined with <emphasis>--verify</emphasis> this\r
124         can be used to silently check if a reference exists.\r
125 </simpara>\r
126 </listitem>\r
127 </varlistentry>\r
128 <varlistentry>\r
129 <term>\r
130 --exclude-existing[=&lt;pattern&gt;]\r
131 </term>\r
132 <listitem>\r
133 <simpara>\r
134         Make <emphasis>git show-ref</emphasis> act as a filter that reads refs from stdin of the\r
135         form "<emphasis>^(?:&lt;anything&gt;\s)?&lt;refname&gt;(?:\^{})?$</emphasis>"\r
136         and performs the following actions on each:\r
137         (1) strip "&#94;{}" at the end of line if any;\r
138         (2) ignore if pattern is provided and does not head-match refname;\r
139         (3) warn if refname is not a well-formed refname and skip;\r
140         (4) ignore if refname is a ref that exists in the local repository;\r
141         (5) otherwise output the line.\r
142 </simpara>\r
143 </listitem>\r
144 </varlistentry>\r
145 <varlistentry>\r
146 <term>\r
147 &lt;pattern&gt;&#8230;\r
148 </term>\r
149 <listitem>\r
150 <simpara>\r
151         Show references matching one or more patterns. Patterns are matched from\r
152         the end of the full name, and only complete parts are matched, e.g.\r
153         <emphasis>master</emphasis> matches <emphasis>refs/heads/master</emphasis>, <emphasis>refs/remotes/origin/master</emphasis>,\r
154         <emphasis>refs/tags/jedi/master</emphasis> but not <emphasis>refs/heads/mymaster</emphasis> or\r
155         <emphasis>refs/remotes/master/jedi</emphasis>.\r
156 </simpara>\r
157 </listitem>\r
158 </varlistentry>\r
159 </variablelist>\r
160 </simplesect>\r
161 <simplesect id="git-show-ref(1)__output">\r
162 <title>OUTPUT</title>\r
163 <simpara>The output is in the format: <emphasis>&lt;SHA-1 ID&gt;</emphasis> <emphasis>&lt;space&gt;</emphasis> <emphasis>&lt;reference name&gt;</emphasis>.</simpara>\r
164 <screen>$ git show-ref --head --dereference\r
165 832e76a9899f560a90ffd62ae2ce83bbeff58f54 HEAD\r
166 832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/master\r
167 832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/origin\r
168 3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c\r
169 6ddc0964034342519a87fe013781abf31c6db6ad refs/tags/v0.99.9c^{}\r
170 055e4ae3ae6eb344cbabf2a5256a49ea66040131 refs/tags/v1.0rc4\r
171 423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{}\r
172 ...</screen>\r
173 <simpara>When using --hash (and not --dereference) the output format is: <emphasis>&lt;SHA-1 ID&gt;</emphasis></simpara>\r
174 <screen>$ git show-ref --heads --hash\r
175 2e3ba0114a1f52b47df29743d6915d056be13278\r
176 185008ae97960c8d551adcd9e23565194651b5d1\r
177 03adf42c988195b50e1a1935ba5fcbc39b2b029b\r
178 ...</screen>\r
179 </simplesect>\r
180 <simplesect id="git-show-ref(1)__example">\r
181 <title>EXAMPLE</title>\r
182 <simpara>To show all references called "master", whether tags or heads or anything\r
183 else, and regardless of how deep in the reference naming hierarchy they are,\r
184 use:</simpara>\r
185 <screen>        git show-ref master</screen>\r
186 <simpara>This will show "refs/heads/master" but also "refs/remote/other-repo/master",\r
187 if such references exists.</simpara>\r
188 <simpara>When using the <emphasis>--verify</emphasis> flag, the command requires an exact path:</simpara>\r
189 <screen>        git show-ref --verify refs/heads/master</screen>\r
190 <simpara>will only match the exact branch called "master".</simpara>\r
191 <simpara>If nothing matches, <emphasis>git show-ref</emphasis> will return an error code of 1,\r
192 and in the case of verification, it will show an error message.</simpara>\r
193 <simpara>For scripting, you can ask it to be quiet with the "--quiet" flag, which\r
194 allows you to do things like</simpara>\r
195 <screen>        git show-ref --quiet --verify -- "refs/heads/$headname" ||\r
196                 echo "$headname is not a valid branch"</screen>\r
197 <simpara>to check whether a particular branch exists or not (notice how we don't\r
198 actually want to show any results, and we want to use the full refname for it\r
199 in order to not trigger the problem with ambiguous partial matches).</simpara>\r
200 <simpara>To show only tags, or only proper branch heads, use "--tags" and/or "--heads"\r
201 respectively (using both means that it shows tags and heads, but not other\r
202 random references under the refs/ subdirectory).</simpara>\r
203 <simpara>To do automatic tag object dereferencing, use the "-d" or "--dereference"\r
204 flag, so you can do</simpara>\r
205 <screen>        git show-ref --tags --dereference</screen>\r
206 <simpara>to get a listing of all tags together with what they dereference.</simpara>\r
207 </simplesect>\r
208 <simplesect id="git-show-ref(1)__files">\r
209 <title>FILES</title>\r
210 <simpara><emphasis>.git/refs/*</emphasis>, <emphasis>.git/packed-refs</emphasis></simpara>\r
211 </simplesect>\r
212 <simplesect id="git-show-ref(1)__see_also">\r
213 <title>SEE ALSO</title>\r
214 <simpara><xref linkend="git-for-each-ref(1)" />,\r
215 <xref linkend="git-ls-remote(1)" />,\r
216 <xref linkend="git-update-ref(1)" />,\r
217 <xref linkend="gitrepository-layout(5)" /></simpara>\r
218 </simplesect>\r
219 <simplesect id="git-show-ref(1)__git">\r
220 <title>GIT</title>\r
221 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
222 </simplesect>\r
223 </sect2>\r