LinuxCommandLibrary

git-var

Show git internal variable

TLDR

Print the value of a Git logical variable

$ git var [GIT_AUTHOR_IDENT|GIT_COMMITTER_IDENT|GIT_EDITOR|GIT_PAGER]
copy

[l]ist all Git logical variables
$ git var -l
copy

SYNOPSIS

git var [-l | --list] [variable ...]

PARAMETERS

-l, --list
    List names of all available variables instead of printing values

DESCRIPTION

git var is a plumbing command that prints values of Git's internal variables to stdout. These variables include author and committer identities (GIT_AUTHOR_IDENT, GIT_COMMITTER_IDENT), committer date (GIT_COMMITTER_DATE), and Git version (GIT_VERSION). It is designed for scripts and porcelain commands needing this data, not interactive use.

Invoke without options or with -l to list all variables. Specify a variable name as an argument to print its value, e.g., git var GIT_VERSION outputs the full version string like 2.45.2.

Ident variables follow Git's ident format (name <email> date), derived from config, environment, or defaults. Dates use RFC 2822 or ISO 8601 formats. Output is plain text, stable for documented vars, aiding shell parsing like author=$(git var GIT_AUTHOR_IDENT).

Use in hooks, wrappers, or tools automating Git operations. Avoid parsing undocumented output.

CAVEATS

Plumbing command: output format outside documented variables may change without notice. Always specify exact variable names. Not for human-readable display.

AVAILABLE VARIABLES

GIT_AUTHOR_IDENT: Author name <email> date
GIT_COMMITTER_IDENT: Committer name <email> date
GIT_COMMITTER_DATE: Committer timestamp
GIT_VERSION: Full Git version string

HISTORY

Introduced in Git 1.5.3 (February 2007) to expose internals for scripting. Evolved minimally; remains stable plumbing tool in modern Git.

SEE ALSO

Copied to clipboard