1GIT-SHOW-REF(1)                   Git Manual                   GIT-SHOW-REF(1)
2
3
4

NAME

6       git-show-ref - List references in a local repository
7

SYNOPSIS

9       git show-ref [-q|--quiet] [--verify] [--head] [-d|--dereference]
10                    [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags]
11                    [--heads] [--] [<pattern>...]
12       git show-ref --exclude-existing[=<pattern>]
13

DESCRIPTION

15       Displays references available in a local repository along with the
16       associated commit IDs. Results can be filtered using a pattern and tags
17       can be dereferenced into object IDs. Additionally, it can be used to
18       test whether a particular ref exists.
19
20       By default, shows the tags, heads, and remote refs.
21
22       The --exclude-existing form is a filter that does the inverse. It reads
23       refs from stdin, one ref per line, and shows those that don’t exist in
24       the local repository.
25
26       Use of this utility is encouraged in favor of directly accessing files
27       under the .git directory.
28

OPTIONS

30       --head
31           Show the HEAD reference, even if it would normally be filtered out.
32
33       --heads, --tags
34           Limit to "refs/heads" and "refs/tags", respectively. These options
35           are not mutually exclusive; when given both, references stored in
36           "refs/heads" and "refs/tags" are displayed.
37
38       -d, --dereference
39           Dereference tags into object IDs as well. They will be shown with
40           "^{}" appended.
41
42       -s, --hash[=<n>]
43           Only show the SHA-1 hash, not the reference name. When combined
44           with --dereference the dereferenced tag will still be shown after
45           the SHA-1.
46
47       --verify
48           Enable stricter reference checking by requiring an exact ref path.
49           Aside from returning an error code of 1, it will also print an
50           error message if --quiet was not specified.
51
52       --abbrev[=<n>]
53           Abbreviate the object name. When using --hash, you do not have to
54           say --hash --abbrev; --hash=n would do.
55
56       -q, --quiet
57           Do not print any results to stdout. When combined with --verify
58           this can be used to silently check if a reference exists.
59
60       --exclude-existing[=<pattern>]
61           Make git show-ref act as a filter that reads refs from stdin of the
62           form "^(?:<anything>\s)?<refname>(?:\^{})?$" and performs the
63           following actions on each: (1) strip "^{}" at the end of line if
64           any; (2) ignore if pattern is provided and does not head-match
65           refname; (3) warn if refname is not a well-formed refname and skip;
66           (4) ignore if refname is a ref that exists in the local repository;
67           (5) otherwise output the line.
68
69       <pattern>...
70           Show references matching one or more patterns. Patterns are matched
71           from the end of the full name, and only complete parts are matched,
72           e.g.  master matches refs/heads/master, refs/remotes/origin/master,
73           refs/tags/jedi/master but not refs/heads/mymaster or
74           refs/remotes/master/jedi.
75

OUTPUT

77       The output is in the format: <SHA-1 ID> <space> <reference name>.
78
79           $ git show-ref --head --dereference
80           832e76a9899f560a90ffd62ae2ce83bbeff58f54 HEAD
81           832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/master
82           832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/origin
83           3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c
84           6ddc0964034342519a87fe013781abf31c6db6ad refs/tags/v0.99.9c^{}
85           055e4ae3ae6eb344cbabf2a5256a49ea66040131 refs/tags/v1.0rc4
86           423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{}
87           ...
88
89       When using --hash (and not --dereference) the output format is: <SHA-1
90       ID>
91
92           $ git show-ref --heads --hash
93           2e3ba0114a1f52b47df29743d6915d056be13278
94           185008ae97960c8d551adcd9e23565194651b5d1
95           03adf42c988195b50e1a1935ba5fcbc39b2b029b
96           ...
97

EXAMPLES

99       To show all references called "master", whether tags or heads or
100       anything else, and regardless of how deep in the reference naming
101       hierarchy they are, use:
102
103                   git show-ref master
104
105       This will show "refs/heads/master" but also
106       "refs/remote/other-repo/master", if such references exists.
107
108       When using the --verify flag, the command requires an exact path:
109
110                   git show-ref --verify refs/heads/master
111
112       will only match the exact branch called "master".
113
114       If nothing matches, git show-ref will return an error code of 1, and in
115       the case of verification, it will show an error message.
116
117       For scripting, you can ask it to be quiet with the "--quiet" flag,
118       which allows you to do things like
119
120                   git show-ref --quiet --verify -- "refs/heads/$headname" ||
121                           echo "$headname is not a valid branch"
122
123       to check whether a particular branch exists or not (notice how we don’t
124       actually want to show any results, and we want to use the full refname
125       for it in order to not trigger the problem with ambiguous partial
126       matches).
127
128       To show only tags, or only proper branch heads, use "--tags" and/or
129       "--heads" respectively (using both means that it shows tags and heads,
130       but not other random references under the refs/ subdirectory).
131
132       To do automatic tag object dereferencing, use the "-d" or
133       "--dereference" flag, so you can do
134
135                   git show-ref --tags --dereference
136
137       to get a listing of all tags together with what they dereference.
138

FILES

140       .git/refs/*, .git/packed-refs
141

SEE ALSO

143       git-for-each-ref(1), git-ls-remote(1), git-update-ref(1),
144       gitrepository-layout(5)
145

GIT

147       Part of the git(1) suite
148
149
150
151Git 2.30.2                        2021-03-08                   GIT-SHOW-REF(1)
Impressum