Skip to content
Tutorials Center
My learning

Topics

Git Reference ยท Setup and Basics

git version command

Reference for git version and git --version: print the Git version, add --build-options for compiler and feature details, and compare versions in scripts.

git version prints the version of Git you are running. git --version and git -v print the same line. Add --build-options to also see how that binary was built: the compiler, the CPU architecture, whether it has libcurl or OpenSSL, the default hash algorithm and more.

The version tells you which commands and options exist. Features such as git switch (2.23), git restore (2.23), the git config set subcommands (2.46) or SHA-256 repositories need a minimum version, so this is the first thing to check when an example from a tutorial fails on your machine.

Terminal
git version [--build-options]
git --version

Try it

Bash Version string and parsing it

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Build options and a minimum-version check

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
git version [--build-options]
git --version
git -v
Name Description
--build-options After the version line, print one key: value line per build property: cpu, sizeof-long, sizeof-size_t, shell-path, libcurl, OpenSSL, zlib, default-hash, default-ref-format and, when known, commit, which is the full commit ID the binary was built from. The list varies by build and version.

Output: git version 2.56.0 on a release. Vendor builds append a suffix, for example git version 2.45.1.windows.1 or git version 2.39.5 (Apple Git-154). Builds from a development checkout show a .g<hash> or .rc suffix.

Exit status: 0. git version never needs a repository and works anywhere.

Usage notes

  • Parsing. The output format is stable enough for scripts, but vendor suffixes make naive comparisons fragile. Use sort -V or the major and minor numbers, as in the example, and ignore the suffix.
  • Multiple installs. which git (or where git) tells you which binary runs. On Windows with several tools installed, the first one on PATH wins; the output of git version --build-options then shows the actual build.
  • Bug reports. Include the full output of git version --build-options. The git bugreport command collects it for you along with the platform details.
  • Not the repository format. The version of Git is unrelated to the repository's own core.repositoryformatversion, which stays 0 for almost all repositories (and 1 when extensions like SHA-256 or worktree config are active). Newer Git reads old repositories; very old Git cannot read repositories that use new extensions.
  • Feature names in this reference note the version where a command or option appeared ("added in 2.23"). If your Git is older than that, upgrade rather than looking for workarounds.
  • Release rhythm. Git ships a feature release every few months (X.Y.0), followed by patch releases (X.Y.Z) that only fix bugs and security issues. Security fixes make staying within the latest patch of a release worthwhile.