logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

git-show-ref.1 (7985B)


  1. '\" t
  2. .\" Title: git-show-ref
  3. .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
  4. .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
  5. .\" Date: 2025-03-14
  6. .\" Manual: Git Manual
  7. .\" Source: Git 2.49.0
  8. .\" Language: English
  9. .\"
  10. .TH "GIT\-SHOW\-REF" "1" "2025-03-14" "Git 2\&.49\&.0" "Git Manual"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. git-show-ref \- List references in a local repository
  32. .SH "SYNOPSIS"
  33. .sp
  34. .nf
  35. \fIgit show\-ref\fR [\-\-head] [\-d | \-\-dereference]
  36. [\-s | \-\-hash[=<n>]] [\-\-abbrev[=<n>]] [\-\-branches] [\-\-tags]
  37. [\-\-] [<pattern>\&...\:]
  38. \fIgit show\-ref\fR \-\-verify [\-q | \-\-quiet] [\-d | \-\-dereference]
  39. [\-s | \-\-hash[=<n>]] [\-\-abbrev[=<n>]]
  40. [\-\-] [<ref>\&...\:]
  41. \fIgit show\-ref\fR \-\-exclude\-existing[=<pattern>]
  42. \fIgit show\-ref\fR \-\-exists <ref>
  43. .fi
  44. .SH "DESCRIPTION"
  45. .sp
  46. 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\&.
  47. .sp
  48. By default, shows the tags, heads, and remote refs\&.
  49. .sp
  50. The \fB\-\-exclude\-existing\fR form is a filter that does the inverse\&. It reads refs from stdin, one ref per line, and shows those that don\(cqt exist in the local repository\&.
  51. .sp
  52. The \fB\-\-exists\fR 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\&.
  53. .sp
  54. Use of this utility is encouraged in favor of directly accessing files under the \&.\fBgit\fR directory\&.
  55. .SH "OPTIONS"
  56. .PP
  57. \-\-head
  58. .RS 4
  59. Show the HEAD reference, even if it would normally be filtered out\&.
  60. .RE
  61. .PP
  62. \-\-branches, \-\-tags
  63. .RS 4
  64. 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
  65. \fB\-\-heads\fR
  66. is a deprecated synonym for
  67. \fB\-\-branches\fR
  68. and may be removed in the future\&.
  69. .RE
  70. .PP
  71. \-d, \-\-dereference
  72. .RS 4
  73. Dereference tags into object IDs as well\&. They will be shown with
  74. \fB^\fR{} appended\&.
  75. .RE
  76. .PP
  77. \-s, \-\-hash[=<n>]
  78. .RS 4
  79. Only show the OID, not the reference name\&. When combined with
  80. \fB\-\-dereference\fR, the dereferenced tag will still be shown after the OID\&.
  81. .RE
  82. .PP
  83. \-\-verify
  84. .RS 4
  85. 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
  86. \fB\-\-quiet\fR
  87. was not specified\&.
  88. .RE
  89. .PP
  90. \-\-exists
  91. .RS 4
  92. 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\&.
  93. .RE
  94. .PP
  95. \-\-abbrev[=<n>]
  96. .RS 4
  97. Abbreviate the object name\&. When using
  98. \fB\-\-hash\fR, you do not have to say
  99. \fB\-\-hash\fR
  100. \fB\-\-abbrev\fR;
  101. \fB\-\-hash=n\fR
  102. would do\&.
  103. .RE
  104. .PP
  105. \-q, \-\-quiet
  106. .RS 4
  107. Do not print any results to stdout\&. Can be used with
  108. \fB\-\-verify\fR
  109. to silently check if a reference exists\&.
  110. .RE
  111. .PP
  112. \-\-exclude\-existing[=<pattern>]
  113. .RS 4
  114. Make
  115. \fBgit\fR
  116. \fBshow\-ref\fR
  117. act as a filter that reads refs from stdin of the form
  118. \fB^\fR(?:\fI<anything>\fR\es)?\fI<refname>\fR(?:\e^{})?$ and performs the following actions on each: (1) strip
  119. \fB^\fR{} 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\&.
  120. .RE
  121. .PP
  122. <pattern>\&...\:
  123. .RS 4
  124. 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\&.
  125. \fImaster\fR
  126. matches
  127. \fIrefs/heads/master\fR,
  128. \fIrefs/remotes/origin/master\fR,
  129. \fIrefs/tags/jedi/master\fR
  130. but not
  131. \fIrefs/heads/mymaster\fR
  132. or
  133. \fIrefs/remotes/master/jedi\fR\&.
  134. .RE
  135. .SH "OUTPUT"
  136. .sp
  137. The output is in the format:
  138. .sp
  139. .if n \{\
  140. .RS 4
  141. .\}
  142. .nf
  143. <oid> SP <ref> LF
  144. .fi
  145. .if n \{\
  146. .RE
  147. .\}
  148. .sp
  149. For example,
  150. .sp
  151. .if n \{\
  152. .RS 4
  153. .\}
  154. .nf
  155. $ git show\-ref \-\-head \-\-dereference
  156. 832e76a9899f560a90ffd62ae2ce83bbeff58f54 HEAD
  157. 832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/master
  158. 832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/origin
  159. 3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0\&.99\&.9c
  160. 6ddc0964034342519a87fe013781abf31c6db6ad refs/tags/v0\&.99\&.9c^{}
  161. 055e4ae3ae6eb344cbabf2a5256a49ea66040131 refs/tags/v1\&.0rc4
  162. 423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1\&.0rc4^{}
  163. \&.\&.\&.
  164. .fi
  165. .if n \{\
  166. .RE
  167. .\}
  168. .sp
  169. When using \fB\-\-hash\fR (and not \fB\-\-dereference\fR), the output is in the format:
  170. .sp
  171. .if n \{\
  172. .RS 4
  173. .\}
  174. .nf
  175. <oid> LF
  176. .fi
  177. .if n \{\
  178. .RE
  179. .\}
  180. .sp
  181. For example,
  182. .sp
  183. .if n \{\
  184. .RS 4
  185. .\}
  186. .nf
  187. $ git show\-ref \-\-branches \-\-hash
  188. 2e3ba0114a1f52b47df29743d6915d056be13278
  189. 185008ae97960c8d551adcd9e23565194651b5d1
  190. 03adf42c988195b50e1a1935ba5fcbc39b2b029b
  191. \&.\&.\&.
  192. .fi
  193. .if n \{\
  194. .RE
  195. .\}
  196. .SH "EXAMPLES"
  197. .sp
  198. 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:
  199. .sp
  200. .if n \{\
  201. .RS 4
  202. .\}
  203. .nf
  204. git show\-ref master
  205. .fi
  206. .if n \{\
  207. .RE
  208. .\}
  209. .sp
  210. This will show "refs/heads/master" but also "refs/remote/other\-repo/master", if such references exist\&.
  211. .sp
  212. When using the \fB\-\-verify\fR flag, the command requires an exact path:
  213. .sp
  214. .if n \{\
  215. .RS 4
  216. .\}
  217. .nf
  218. git show\-ref \-\-verify refs/heads/master
  219. .fi
  220. .if n \{\
  221. .RE
  222. .\}
  223. .sp
  224. will only match the exact branch called "master"\&.
  225. .sp
  226. If nothing matches, \fBgit\fR \fBshow\-ref\fR will return an error code of 1, and in the case of verification, it will show an error message\&.
  227. .sp
  228. For scripting, you can ask it to be quiet with the \fB\-\-quiet\fR flag, which allows you to do things like
  229. .sp
  230. .if n \{\
  231. .RS 4
  232. .\}
  233. .nf
  234. git show\-ref \-\-quiet \-\-verify \-\- "refs/heads/$headname" ||
  235. echo "$headname is not a valid branch"
  236. .fi
  237. .if n \{\
  238. .RE
  239. .\}
  240. .sp
  241. to check whether a particular branch exists or not (notice how we don\(cqt 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)\&.
  242. .sp
  243. To show only tags, or only proper branch heads, use \fB\-\-tags\fR and/or \fB\-\-branches\fR respectively (using both means that it shows tags and branches, but not other random references under the refs/ subdirectory)\&.
  244. .sp
  245. To do automatic tag object dereferencing, use the \fB\-d\fR or \fB\-\-dereference\fR flag, so you can do
  246. .sp
  247. .if n \{\
  248. .RS 4
  249. .\}
  250. .nf
  251. git show\-ref \-\-tags \-\-dereference
  252. .fi
  253. .if n \{\
  254. .RE
  255. .\}
  256. .sp
  257. to get a listing of all tags together with what they dereference\&.
  258. .SH "FILES"
  259. .sp
  260. \&.\fBgit/refs/\fR*, \&.\fBgit/packed\-refs\fR
  261. .SH "SEE ALSO"
  262. .sp
  263. \fBgit-for-each-ref\fR(1), \fBgit-ls-remote\fR(1), \fBgit-update-ref\fR(1), \fBgitrepository-layout\fR(5)
  264. .SH "GIT"
  265. .sp
  266. Part of the \fBgit\fR(1) suite