git-show-ref - Linux


git-show-ref is a versatile command used to list, filter, create, and delete references (branches, tags, and remotes) in a Git repository. It provides detailed information about the structure and state of the repository.


git show-ref [--all] [--branch] [--tag] [--remote] [--glob=<pattern>] [--heads]


  • <commit-ish>: One or more commit-ish references (e.g., branches, tags, commits) to display information about. If omitted, all references are shown.


Listing Options:

  • --all: List all references, including local and remote.
  • --branch: List only local branches.
  • --tag: List only tags.
  • --remote: List only remote-tracking branches.

Filtering Options:

  • --glob=<pattern>: Filter references matching the given glob pattern.
  • --heads: List only the current HEAD of each branch.

Miscellaneous Options:

  • --dereference: Display the commit SHA-1 instead of the symbolic name for each reference.


List all references:

git show-ref

List only local branches:

git show-ref --branch

List tags matching a pattern:

git show-ref --tag --glob='v*'

List only the current HEAD of each branch:

git show-ref --heads

Common Issues

  • No references found: Ensure that the repository is not empty and that you have the correct permissions to access the references.
  • Invalid glob pattern: Check that the provided glob pattern is syntactically correct.


Combine with git branch:

git branch | git show-ref

Create a new reference:

git show-ref --create development
git show-ref refs/heads/development

Delete a reference:

git show-ref --delete origin/develop
git show-ref

Related Commands