LinuxCommandLibrary

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

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

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community