LinuxCommandLibrary

git-show-ref

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 [options] [pattern]

DESCRIPTION

git show-ref lists references in the repository. It shows SHA-1 hashes and ref names for branches, tags, and other refs.
The command is useful for scripting and ref verification. Verify mode checks if a specific ref exists without listing all refs.
git show-ref provides ref enumeration and verification.

PARAMETERS

PATTERN

Filter refs by pattern.
--heads
Show only heads.
--tags
Show only tags.
--verify
Verify ref exists.
-q, --quiet
No output, exit code only.
--hash
Show hash only.
-d, --dereference
Dereference tags.
--help
Display help information.

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