To check your Git version, run git --version in your terminal. This command returns the installed Git version number and build details, confirming whether Git is properly installed and which release you're using.
The git --version command is the standard method across all operating systems. It requires no additional tools or configuration. The output includes the version number, such as git version 2.44.0, and may list the build environment, like Apple Git-156 on macOS or GNU/Linux on Debian-based systems.
Use this command whenever you need to confirm compatibility with project requirements, debug issues related to Git features, or validate that updates have applied correctly. It's the fastest way to verify your Git setup.
When you run git --version, the Git binary parses the command-line argument and outputs the version string stored in its internal metadata. This string is compiled into the executable during installation and reflects the official release tag from the Git source repository.
Git does not connect to the internet to fetch version data. The version is entirely local and static. If the command fails, it means Git is either not installed or not in your system's PATH.
For example, running git --version on a fresh Ubuntu 22.04 install returns:
git version 2.34.1
This indicates the version bundled with the OS package manager. If you've installed a newer version via a PPA or source build, the output will reflect that.
Different Git versions support varying sets of commands and behaviors. Knowing your version helps avoid unexpected results in scripts or team workflows.
| Version | Key Features | Relevance |
|---|---|---|
| 2.17.0+ | Native support for git switch and git restore |
Standard in most modern distributions since 2018 |
| 2.30.0+ | Improved handling of sparse-checkout and partial clones | Required for efficient large-repo workflows |
| 2.40.0+ | Enhanced merge conflict resolution and improved performance on Windows | Recommended for teams using GitHub Enterprise |
Projects that rely on newer Git features may fail silently on older versions. For example, using git switch --create in a script will error on Git 2.16 or earlier because the command doesn't exist.
A non-obvious difference: Git 2.35 introduced stricter validation for commit messages in hooks. Some CI/CD pipelines fail unexpectedly after an update due to this change, even though the version number increased by only one minor release.
You should check your Git version before cloning repositories, setting up CI/CD pipelines, or contributing to open-source projects. Many documentation guides assume a minimum version.
For example, the official Git documentation states that certain configuration options require Git 2.28 or later. Running git --version prevents wasted time debugging configuration errors that stem from outdated software.
Team environments often enforce version policies. A company might require all developers to use Git 2.35 or higher to ensure consistent behavior across platforms. Checking the version ensures compliance and avoids merge conflicts caused by differing default settings.
I once encountered a failed deployment where the pipeline hung indefinitely. After checking the runner's Git version, I found it was 2.17.1 - too old to handle a new git push --force-with-lease command. Upgrading to 2.35 resolved the issue in under five minutes.
Developers sometimes mistake git --version for git help or git config --list. These commands serve different purposes: git help shows usage instructions, while git config --list displays user-specific settings like name and email.
Another common mix-up is confusing git --version with git --help. The latter provides command syntax and examples, while the former returns only the version string.
Some users attempt to check the version through IDE integrations (like VS Code or IntelliJ). While these tools display Git status, they don't show the underlying Git binary version. Relying solely on the IDE interface risks missing version mismatches between local tools and remote servers.
If git --version returns command not found, Git is not installed or not in your PATH. On Ubuntu, install it with sudo apt install git. On macOS, use brew install git.
If the output shows a very old version (e.g., 1.8.5), the system package manager may be outdated. Update your distribution's package index first, then reinstall Git. On CentOS, run sudo yum update git.
For custom builds or containerized environments, verify the path to the Git binary. Run which git to locate it. If it points to a local directory, ensure the binary is up to date.
When working in Docker containers, always specify the Git version explicitly in your Dockerfile. Using FROM alpine:latest without installing Git leads to missing commands. Add RUN apk add --no-cache git to ensure the correct version is available.
After confirming your Git version, verify that your Git configuration is set correctly. Run git config --get user.name and git config --get user.email to ensure commits are attributed properly.
Always use git --version as the first step in diagnosing Git-related issues. It's fast, accurate, and universally supported.