1git-show-ref(1) 2=============== 3 4NAME 5---- 6git-show-ref - List references in a local repository 7 8SYNOPSIS 9-------- 10[verse] 11'git-show-ref' [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] 12 [--tags] [--heads] [--] <pattern>... 13 14DESCRIPTION 15----------- 16 17Displays references available in a local repository along with the associated 18commit IDs. Results can be filtered using a pattern and tags can be 19dereferenced into object IDs. Additionally, it can be used to test whether a 20particular ref exists. 21 22Use of this utility is encouraged in favor of directly accessing files under 23in the `.git` directory. 24 25OPTIONS 26------- 27 28-h, --head:: 29 30 Show the HEAD reference. 31 32--tags, --heads:: 33 34 Limit to only "refs/heads" and "refs/tags", respectively. These 35 options are not mutually exclusive; when given both, references stored 36 in "refs/heads" and "refs/tags" are displayed. 37 38-d, --dereference:: 39 40 Dereference tags into object IDs. They will be shown with "^{}" 41 appended. 42 43--verify:: 44 45 Enable stricter reference checking by requiring an exact ref path. 46 Aside from returning an error code of 1, it will also print an error 47 message if '--quiet' was not specified. 48 49-q, --quiet:: 50 51 Do not print any results to stdout. When combined with '--verify' this 52 can be used to silently check if a reference exists. 53 54<pattern>:: 55 56 Show references matching one or more patterns. 57 58OUTPUT 59------ 60 61The output is in the format: '<SHA-1 ID>' '<space>' '<reference name>'. 62 63----------------------------------------------------------------------------- 64$ git show-ref --head --dereference 65832e76a9899f560a90ffd62ae2ce83bbeff58f54 HEAD 66832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/master 67832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/origin 683521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c 696ddc0964034342519a87fe013781abf31c6db6ad refs/tags/v0.99.9c^{} 70055e4ae3ae6eb344cbabf2a5256a49ea66040131 refs/tags/v1.0rc4 71423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{} 72... 73----------------------------------------------------------------------------- 74 75EXAMPLE 76------- 77 78To show all references called "master", whether tags or heads or anything 79else, and regardless of how deep in the reference naming hierarchy they are, 80use: 81 82----------------------------------------------------------------------------- 83 git show-ref master 84----------------------------------------------------------------------------- 85 86This will show "refs/heads/master" but also "refs/remote/other-repo/master", 87if such references exists. 88 89When using the '--verify' flag, the command requires an exact path: 90 91----------------------------------------------------------------------------- 92 git show-ref --verify refs/heads/master 93----------------------------------------------------------------------------- 94 95will only match the exact branch called "master". 96 97If nothing matches, gitlink:git-show-ref[1] will return an error code of 1, 98and in the case of verification, it will show an error message. 99 100For scripting, you can ask it to be quiet with the "--quiet" flag, which 101allows you to do things like 102 103----------------------------------------------------------------------------- 104 git-show-ref --quiet --verify -- "refs/heads/$headname" || 105 echo "$headname is not a valid branch" 106----------------------------------------------------------------------------- 107 108to check whether a particular branch exists or not (notice how we don't 109actually want to show any results, and we want to use the full refname for it 110in order to not trigger the problem with ambiguous partial matches). 111 112To show only tags, or only proper branch heads, use "--tags" and/or "--heads" 113respectively (using both means that it shows tags and heads, but not other 114random references under the refs/ subdirectory). 115 116To do automatic tag object dereferencing, use the "-d" or "--dereference" 117flag, so you can do 118 119----------------------------------------------------------------------------- 120 git show-ref --tags --dereference 121----------------------------------------------------------------------------- 122 123to get a listing of all tags together with what they dereference. 124 125SEE ALSO 126-------- 127gitlink:git-ls-remote[1], gitlink:git-peek-remote[1] 128 129AUTHORS 130------- 131Written by Linus Torvalds <torvalds@osdl.org>. 132Man page by Jonas Fonseca <fonseca@diku.dk>. 133 134GIT 135--- 136Part of the gitlink:git[7] suite