LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git-show-ref

List references in the local repository

TLDR

List all refs
$ git show-ref
copy
Show heads only
$ git show-ref --heads
copy
Show tags only
$ git show-ref --tags
copy
Verify ref exists
$ git show-ref --verify refs/heads/main
copy
Quiet mode
$ git show-ref -q --verify refs/heads/main
copy

SYNOPSIS

git show-ref [--head] [-d | --dereference] [-s | --hash[=N]] [--abbrev[=N]] [--branches] [--tags] [--] [pattern...]git show-ref --verify [-q | --quiet] [-d | --dereference] [-s | --hash[=N]] [--abbrev[=N]] [--] [ref...]git show-ref --exists refgit show-ref --exclude-existing[=pattern]

DESCRIPTION

git show-ref lists references in the local repository, showing SHA-1 hashes and ref names for branches, tags, and other refs. It is a plumbing command commonly used in scripts.The verify mode checks whether a specific ref exists without listing all refs, returning an appropriate exit code.

PARAMETERS

PATTERN

Match refs whose end matches the pattern (matched in complete parts).
--head
Include the HEAD reference, which is filtered out by default.
--branches
Limit to local branches (refs/heads). Replaces the older --heads, which still works as an alias.
--tags
Limit to local tags (refs/tags).
--verify
Require the argument to be an exact ref path (e.g. refs/heads/main). Errors if the ref does not exist.
--exists ref
Check whether a ref exists. Exit code 0 = exists, 2 = missing, 1 = error.
--exclude-existing[=pattern]
Filter mode. Reads refs from stdin and prints those that do not exist locally, optionally limited to refs matching the pattern suffix.
-q, --quiet
Suppress output. Use the exit code only.
-s, --hash[=N]
Print only the object name (optionally abbreviated to N hex digits), not the ref name.
--abbrev[=N]
Abbreviate the printed object name to N hex digits (default uses core.abbrev).
-d, --dereference
For tag objects, also print the dereferenced commit, suffixed with ^{}.

CAVEATS

Plumbing command. Shows local refs only. Use git ls-remote for remote refs.

HISTORY

git show-ref is a core Git plumbing command for reference inspection, commonly used in scripts.

SEE ALSO

Copied to clipboard
Kai