Junio C Hamano | a2ec14f | 2006-11-02 00:22:48 | [diff] [blame] | 1 | git-show-ref(1) |
| 2 | =============== |
| 3 | |
| 4 | NAME |
| 5 | ---- |
| 6 | git-show-ref - List references in a local repository |
| 7 | |
| 8 | SYNOPSIS |
| 9 | -------- |
| 10 | [verse] |
| 11 | 'git-show-ref' [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] |
| 12 | [-s|--hash] [--abbrev] [--tags] [--heads] [--] <pattern>... |
| 13 | |
| 14 | DESCRIPTION |
| 15 | ----------- |
| 16 | |
| 17 | Displays references available in a local repository along with the associated |
| 18 | commit IDs. Results can be filtered using a pattern and tags can be |
| 19 | dereferenced into object IDs. Additionally, it can be used to test whether a |
| 20 | particular ref exists. |
| 21 | |
| 22 | Use of this utility is encouraged in favor of directly accessing files under |
| 23 | in the `.git` directory. |
| 24 | |
| 25 | OPTIONS |
| 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 as well. They will be shown with "^{}" |
| 41 | appended. |
| 42 | |
| 43 | -s, --hash:: |
| 44 | |
| 45 | Only show the SHA1 hash, not the reference name. When also using |
| 46 | --dereference the dereferenced tag will still be shown after the SHA1. |
| 47 | |
| 48 | --verify:: |
| 49 | |
| 50 | Enable stricter reference checking by requiring an exact ref path. |
| 51 | Aside from returning an error code of 1, it will also print an error |
| 52 | message if '--quiet' was not specified. |
| 53 | |
| 54 | --abbrev, --abbrev=len:: |
| 55 | |
| 56 | Abbreviate the object name. When using `--hash`, you do |
| 57 | not have to say `--hash --abbrev`; `--hash=len` would do. |
| 58 | |
| 59 | -q, --quiet:: |
| 60 | |
| 61 | Do not print any results to stdout. When combined with '--verify' this |
| 62 | can be used to silently check if a reference exists. |
| 63 | |
| 64 | <pattern>:: |
| 65 | |
| 66 | Show references matching one or more patterns. |
| 67 | |
| 68 | OUTPUT |
| 69 | ------ |
| 70 | |
| 71 | The output is in the format: '<SHA-1 ID>' '<space>' '<reference name>'. |
| 72 | |
| 73 | ----------------------------------------------------------------------------- |
| 74 | $ git show-ref --head --dereference |
| 75 | 832e76a9899f560a90ffd62ae2ce83bbeff58f54 HEAD |
| 76 | 832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/master |
| 77 | 832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/origin |
| 78 | 3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c |
| 79 | 6ddc0964034342519a87fe013781abf31c6db6ad refs/tags/v0.99.9c^{} |
| 80 | 055e4ae3ae6eb344cbabf2a5256a49ea66040131 refs/tags/v1.0rc4 |
| 81 | 423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{} |
| 82 | ... |
| 83 | ----------------------------------------------------------------------------- |
| 84 | |
| 85 | When using --hash (and not --dereference) the output format is: '<SHA-1 ID>' |
| 86 | |
| 87 | ----------------------------------------------------------------------------- |
| 88 | $ git show-ref --heads --hash |
| 89 | 2e3ba0114a1f52b47df29743d6915d056be13278 |
| 90 | 185008ae97960c8d551adcd9e23565194651b5d1 |
| 91 | 03adf42c988195b50e1a1935ba5fcbc39b2b029b |
| 92 | ... |
| 93 | ----------------------------------------------------------------------------- |
| 94 | |
| 95 | EXAMPLE |
| 96 | ------- |
| 97 | |
| 98 | To show all references called "master", whether tags or heads or anything |
| 99 | else, and regardless of how deep in the reference naming hierarchy they are, |
| 100 | use: |
| 101 | |
| 102 | ----------------------------------------------------------------------------- |
| 103 | git show-ref master |
| 104 | ----------------------------------------------------------------------------- |
| 105 | |
| 106 | This will show "refs/heads/master" but also "refs/remote/other-repo/master", |
| 107 | if such references exists. |
| 108 | |
| 109 | When using the '--verify' flag, the command requires an exact path: |
| 110 | |
| 111 | ----------------------------------------------------------------------------- |
| 112 | git show-ref --verify refs/heads/master |
| 113 | ----------------------------------------------------------------------------- |
| 114 | |
| 115 | will only match the exact branch called "master". |
| 116 | |
| 117 | If nothing matches, gitlink:git-show-ref[1] will return an error code of 1, |
| 118 | and in the case of verification, it will show an error message. |
| 119 | |
| 120 | For scripting, you can ask it to be quiet with the "--quiet" flag, which |
| 121 | allows you to do things like |
| 122 | |
| 123 | ----------------------------------------------------------------------------- |
| 124 | git-show-ref --quiet --verify -- "refs/heads/$headname" || |
| 125 | echo "$headname is not a valid branch" |
| 126 | ----------------------------------------------------------------------------- |
| 127 | |
| 128 | to check whether a particular branch exists or not (notice how we don't |
| 129 | actually want to show any results, and we want to use the full refname for it |
| 130 | in order to not trigger the problem with ambiguous partial matches). |
| 131 | |
| 132 | To show only tags, or only proper branch heads, use "--tags" and/or "--heads" |
| 133 | respectively (using both means that it shows tags and heads, but not other |
| 134 | random references under the refs/ subdirectory). |
| 135 | |
| 136 | To do automatic tag object dereferencing, use the "-d" or "--dereference" |
| 137 | flag, so you can do |
| 138 | |
| 139 | ----------------------------------------------------------------------------- |
| 140 | git show-ref --tags --dereference |
| 141 | ----------------------------------------------------------------------------- |
| 142 | |
| 143 | to get a listing of all tags together with what they dereference. |
| 144 | |
| 145 | SEE ALSO |
| 146 | -------- |
| 147 | gitlink:git-ls-remote[1], gitlink:git-peek-remote[1] |
| 148 | |
| 149 | AUTHORS |
| 150 | ------- |
| 151 | Written by Linus Torvalds <torvalds@osdl.org>. |
| 152 | Man page by Jonas Fonseca <fonseca@diku.dk>. |
| 153 | |
| 154 | GIT |
| 155 | --- |
| 156 | Part of the gitlink:git[7] suite |