git-for-each-ref
Output information on each reference with custom formatting
TLDR
SYNOPSIS
git for-each-ref [options] [patterns...]
DESCRIPTION
git for-each-ref is a plumbing command that outputs detailed information about Git references (branches, tags, remote branches) in a highly customizable format. It serves as the foundation for many higher-level Git commands and scripts that need to process repository references.The format string syntax supports field extraction using %(fieldname) placeholders, with available fields including refname, objecttype, objectname, author, committer, and many others. Sorting capabilities enable ordering references by any field, with support for reverse sorting using a minus prefix.This command is primarily used in scripts and Git aliases rather than direct user interaction. The filtering options (--merged, --no-merged, --points-at) provide powerful selection mechanisms for finding references matching specific criteria.
PARAMETERS
--format format
Output format string using %(fieldname) placeholders (default: `%(objectname) %(objecttype)\t%(refname)`).--sort key
Sort by field name; prefix with - for descending. Repeatable, last key is primary.--count n
Stop after showing n refs.--points-at object
Only list refs pointing at the given object.--merged[=commit]
Only list refs whose tips are reachable from commit (default HEAD).--no-merged[=commit]
Only list refs whose tips are not reachable from commit (default HEAD).--contains[=commit]
Only list refs that contain the given commit.--exclude pattern
Omit refs matching pattern.--stdin
Read the list of patterns from standard input instead of the argument list.--ignore-case
Case-insensitive sorting and filtering.--shell, --perl, --python, --tcl
Quote interpolated values as string literals for the given scripting language.
INSTALL
SEE ALSO
git-branch(1), git-tag(1), git-rev-parse(1)