{
    "mode": "man",
    "parameter": "git-show-ref",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/git-show-ref/1/json",
    "generated": "2026-05-30T06:05:57Z",
    "synopsis": "git show-ref [-q|--quiet] [--verify] [--head] [-d|--dereference]\n[-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags]\n[--heads] [--] [<pattern>...]\ngit show-ref --exclude-existing[=<pattern>]",
    "sections": {
        "NAME": {
            "content": "git-show-ref - List references in a local repository\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "git show-ref [-q|--quiet] [--verify] [--head] [-d|--dereference]\n[-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags]\n[--heads] [--] [<pattern>...]\ngit show-ref --exclude-existing[=<pattern>]\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Displays references available in a local repository along with the associated commit IDs.\nResults can be filtered using a pattern and tags can be dereferenced into object IDs.\nAdditionally, it can be used to test whether a particular ref exists.\n\nBy default, shows the tags, heads, and remote refs.\n\nThe --exclude-existing form is a filter that does the inverse. It reads refs from stdin, one\nref per line, and shows those that don’t exist in the local repository.\n\nUse of this utility is encouraged in favor of directly accessing files under the .git\ndirectory.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "--head",
                    "content": "Show the HEAD reference, even if it would normally be filtered out.\n",
                    "long": "--head"
                },
                {
                    "name": "--heads, --tags",
                    "content": "Limit to \"refs/heads\" and \"refs/tags\", respectively. These options are not mutually\nexclusive; when given both, references stored in \"refs/heads\" and \"refs/tags\" are\ndisplayed.\n",
                    "long": "--tags"
                },
                {
                    "name": "-d, --dereference",
                    "content": "Dereference tags into object IDs as well. They will be shown with \"^{}\" appended.\n\n-s, --hash[=<n>]\nOnly show the SHA-1 hash, not the reference name. When combined with --dereference the\ndereferenced tag will still be shown after the SHA-1.\n",
                    "flag": "-d",
                    "long": "--dereference"
                },
                {
                    "name": "--verify",
                    "content": "Enable stricter reference checking by requiring an exact ref path. Aside from returning\nan error code of 1, it will also print an error message if --quiet was not specified.\n\n--abbrev[=<n>]\nAbbreviate the object name. When using --hash, you do not have to say --hash --abbrev;\n--hash=n would do.\n",
                    "long": "--verify"
                },
                {
                    "name": "-q, --quiet",
                    "content": "Do not print any results to stdout. When combined with --verify this can be used to\nsilently check if a reference exists.\n\n--exclude-existing[=<pattern>]\nMake git show-ref act as a filter that reads refs from stdin of the form\n\"^(?:<anything>\\s)?<refname>(?:\\^{})?$\" and performs the following actions on each: (1)\nstrip \"^{}\" at the end of line if any; (2) ignore if pattern is provided and does not\nhead-match refname; (3) warn if refname is not a well-formed refname and skip; (4) ignore\nif refname is a ref that exists in the local repository; (5) otherwise output the line.\n\n<pattern>...\nShow references matching one or more patterns. Patterns are matched from the end of the\nfull name, and only complete parts are matched, e.g.  master matches refs/heads/master,\nrefs/remotes/origin/master, refs/tags/jedi/master but not refs/heads/mymaster or\nrefs/remotes/master/jedi.\n",
                    "flag": "-q",
                    "long": "--quiet"
                }
            ]
        },
        "OUTPUT": {
            "content": "The output is in the format: <SHA-1 ID> <space> <reference name>.\n\n$ git show-ref --head --dereference\n832e76a9899f560a90ffd62ae2ce83bbeff58f54 HEAD\n832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/master\n832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/origin\n3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c\n6ddc0964034342519a87fe013781abf31c6db6ad refs/tags/v0.99.9c^{}\n055e4ae3ae6eb344cbabf2a5256a49ea66040131 refs/tags/v1.0rc4\n423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{}\n...\n\n\nWhen using --hash (and not --dereference) the output format is: <SHA-1 ID>\n\n$ git show-ref --heads --hash\n2e3ba0114a1f52b47df29743d6915d056be13278\n185008ae97960c8d551adcd9e23565194651b5d1\n03adf42c988195b50e1a1935ba5fcbc39b2b029b\n...\n\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "To show all references called \"master\", whether tags or heads or anything else, and\nregardless of how deep in the reference naming hierarchy they are, use:\n\ngit show-ref master\n\n\nThis will show \"refs/heads/master\" but also \"refs/remote/other-repo/master\", if such\nreferences exists.\n\nWhen using the --verify flag, the command requires an exact path:\n\ngit show-ref --verify refs/heads/master\n\n\nwill only match the exact branch called \"master\".\n\nIf nothing matches, git show-ref will return an error code of 1, and in the case of\nverification, it will show an error message.\n\nFor scripting, you can ask it to be quiet with the \"--quiet\" flag, which allows you to do\nthings like\n\ngit show-ref --quiet --verify -- \"refs/heads/$headname\" ||\necho \"$headname is not a valid branch\"\n\n\nto check whether a particular branch exists or not (notice how we don’t actually want to show\nany results, and we want to use the full refname for it in order to not trigger the problem\nwith ambiguous partial matches).\n\nTo show only tags, or only proper branch heads, use \"--tags\" and/or \"--heads\" respectively\n(using both means that it shows tags and heads, but not other random references under the\nrefs/ subdirectory).\n\nTo do automatic tag object dereferencing, use the \"-d\" or \"--dereference\" flag, so you can do\n\ngit show-ref --tags --dereference\n\n\nto get a listing of all tags together with what they dereference.\n",
            "subsections": []
        },
        "FILES": {
            "content": ".git/refs/*, .git/packed-refs\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "git-for-each-ref(1), git-ls-remote(1), git-update-ref(1), gitrepository-layout(5)\n",
            "subsections": []
        },
        "GIT": {
            "content": "Part of the git(1) suite\n\n\n\nGit 2.34.1                                   02/26/2026                              GIT-SHOW-REF(1)",
            "subsections": []
        }
    },
    "summary": "git-show-ref - List references in a local repository",
    "flags": [
        {
            "flag": "",
            "long": "--head",
            "arg": null,
            "description": "Show the HEAD reference, even if it would normally be filtered out."
        },
        {
            "flag": "",
            "long": "--tags",
            "arg": null,
            "description": "Limit to \"refs/heads\" and \"refs/tags\", respectively. These options are not mutually exclusive; when given both, references stored in \"refs/heads\" and \"refs/tags\" are displayed."
        },
        {
            "flag": "-d",
            "long": "--dereference",
            "arg": null,
            "description": "Dereference tags into object IDs as well. They will be shown with \"^{}\" appended. -s, --hash[=<n>] Only show the SHA-1 hash, not the reference name. When combined with --dereference the dereferenced tag will still be shown after the SHA-1."
        },
        {
            "flag": "",
            "long": "--verify",
            "arg": null,
            "description": "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 --quiet was not specified. --abbrev[=<n>] Abbreviate the object name. When using --hash, you do not have to say --hash --abbrev; --hash=n would do."
        },
        {
            "flag": "-q",
            "long": "--quiet",
            "arg": null,
            "description": "Do not print any results to stdout. When combined with --verify this can be used to silently check if a reference exists. --exclude-existing[=<pattern>] Make git show-ref act as a filter that reads refs from stdin of the form \"^(?:<anything>\\s)?<refname>(?:\\^{})?$\" and performs the following actions on each: (1) strip \"^{}\" 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. <pattern>... 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. master matches refs/heads/master, refs/remotes/origin/master, refs/tags/jedi/master but not refs/heads/mymaster or refs/remotes/master/jedi."
        }
    ],
    "examples": [
        "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:",
        "git show-ref master",
        "This will show \"refs/heads/master\" but also \"refs/remote/other-repo/master\", if such",
        "references exists.",
        "When using the --verify flag, the command requires an exact path:",
        "git show-ref --verify refs/heads/master",
        "will only match the exact branch called \"master\".",
        "If nothing matches, git show-ref will return an error code of 1, and in the case of",
        "verification, it will show an error message.",
        "For scripting, you can ask it to be quiet with the \"--quiet\" flag, which allows you to do",
        "things like",
        "git show-ref --quiet --verify -- \"refs/heads/$headname\" ||",
        "echo \"$headname is not a valid branch\"",
        "to check whether a particular branch exists or not (notice how we don’t 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).",
        "To show only tags, or only proper branch heads, use \"--tags\" and/or \"--heads\" respectively",
        "(using both means that it shows tags and heads, but not other random references under the",
        "refs/ subdirectory).",
        "To do automatic tag object dereferencing, use the \"-d\" or \"--dereference\" flag, so you can do",
        "git show-ref --tags --dereference",
        "to get a listing of all tags together with what they dereference."
    ],
    "see_also": [
        {
            "name": "git-for-each-ref",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-for-each-ref/1/json"
        },
        {
            "name": "git-ls-remote",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-ls-remote/1/json"
        },
        {
            "name": "git-update-ref",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-update-ref/1/json"
        },
        {
            "name": "gitrepository-layout",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/gitrepository-layout/5/json"
        }
    ]
}