Git-for-Each-Ref

ankitg121 pts0 comments

git-for-each-ref(1)

NAME<br>git-for-each-ref - Output information on each ref

SYNOPSIS<br>[verse]<br>'git for-each-ref' [--count=] [--shell|--perl|--python|--tcl]<br>[(--sort=)...] [--format=] [...]<br>[--points-at=]<br>[--merged[=]] [--no-merged[=]]<br>[--contains[=]] [--no-contains[=]]

DESCRIPTION

Iterate over all refs that match `` and show them<br>according to the given ``, after sorting them according<br>to the given set of ``. If `` is given, stop after<br>showing that many refs. The interpolated values in ``<br>can optionally be quoted as string literals in the specified<br>host language allowing their direct evaluation in that language.

OPTIONS<br>...::<br>If one or more patterns are given, only refs are shown that<br>match against at least one pattern, either using fnmatch(3) or<br>literally, in the latter case matching completely or from the<br>beginning up to a slash.

--count=::<br>By default the command shows all refs that match<br>``. This option makes it stop after showing<br>that many refs.

--sort=::<br>A field name to sort on. Prefix `-` to sort in<br>descending order of the value. When unspecified,<br>`refname` is used. You may use the --sort= option<br>multiple times, in which case the last key becomes the primary<br>key.

--format=::<br>A string that interpolates `%(fieldname)` from a ref being shown<br>and the object it points at. If `fieldname`<br>is prefixed with an asterisk (`*`) and the ref points<br>at a tag object, use the value for the field in the object<br>which the tag object refers to (instead of the field in the tag object).<br>When unspecified, `` defaults to<br>`%(objectname) SPC %(objecttype) TAB %(refname)`.<br>It also interpolates `%%` to `%`, and `%xx` where `xx`<br>are hex digits interpolates to character with hex code<br>`xx`; for example `%00` interpolates to `\0` (NUL),<br>`%09` to `\t` (TAB) and `%0a` to `\n` (LF).

--color[=]::<br>Respect any colors specified in the `--format` option. The<br>`` field must be one of `always`, `never`, or `auto` (if<br>`` is absent, behave as if `always` was given).

--shell::<br>--perl::<br>--python::<br>--tcl::<br>If given, strings that substitute `%(fieldname)`<br>placeholders are quoted as string literals suitable for<br>the specified host language. This is meant to produce<br>a scriptlet that can directly be `eval`ed.

--points-at=::<br>Only list refs which points at the given object.

--merged[=]::<br>Only list refs whose tips are reachable from the<br>specified commit (HEAD if not specified).

--no-merged[=]::<br>Only list refs whose tips are not reachable from the<br>specified commit (HEAD if not specified).

--contains[=]::<br>Only list refs which contain the specified commit (HEAD if not<br>specified).

--no-contains[=]::<br>Only list refs which don't contain the specified commit (HEAD<br>if not specified).

--ignore-case::<br>Sorting and filtering refs are case insensitive.

FIELD NAMES

Various values from structured fields in referenced objects can<br>be used to interpolate into the resulting output, or as sort<br>keys.

For all objects, the following names can be used:

refname::<br>The name of the ref (the part after $GIT_DIR/).<br>For a non-ambiguous short name of the ref append `:short`.<br>The option core.warnAmbiguousRefs is used to select the strict<br>abbreviation mode. If `lstrip=` (`rstrip=`) is appended, strips ``<br>slash-separated path components from the front (back) of the refname<br>(e.g. `%(refname:lstrip=2)` turns `refs/tags/foo` into `foo` and<br>`%(refname:rstrip=2)` turns `refs/tags/foo` into `refs`).<br>If `` is a negative number, strip as many path components as<br>necessary from the specified end to leave `-` path components<br>(e.g. `%(refname:lstrip=-2)` turns<br>`refs/tags/foo` into `tags/foo` and `%(refname:rstrip=-1)`<br>turns `refs/tags/foo` into `refs`). When the ref does not have<br>enough components, the result becomes an empty string if<br>stripping with positive , or it becomes the full refname if<br>stripping with negative . Neither is an error.<br>`strip` can be used as a synonym to `lstrip`.

objecttype::<br>The type of the object (`blob`, `tree`, `commit`, `tag`).

objectsize::<br>The size of the object (the same as 'git cat-file -s' reports).<br>Append `:disk` to get the size, in bytes, that the object takes up on<br>disk. See the note about on-disk sizes in the `CAVEATS` section below.<br>objectname::<br>The object name (aka SHA-1).<br>For a non-ambiguous abbreviation of the object name append `:short`.<br>For an abbreviation of the object name with desired length append<br>`:short=`, where the minimum length is MINIMUM_ABBREV. The<br>length may be exceeded to ensure unique object names.<br>deltabase::<br>This expands to the object name of the delta base for the<br>given object, if it is stored as a delta. Otherwise it<br>expands to the null object name (all zeroes).

upstream::<br>The name of a local ref which can be considered ``upstream''<br>from the displayed ref. Respects `:short`, `:lstrip` and<br>`:rstrip` in the same way as `refname` above. Additionally<br>respects `:track` to show "[ahead N, behind M]" and<br>`:trackshort` to show the terse version: ">" (ahead), "" (ahead and behind), or "=" (in sync). `:track`<br>also prints "[gone]"...

refs object specified name refname given

Related Articles