Install Git
On this page, you will find useful information about Git installation learning how to install Git from source; how to install it on Mac, Windows and Linux.
Before you can clone a repository, make a commit, or open a pull request, Git has to live on your machine. This page covers every common way to install Git on macOS, Windows, and Linux, how to build it from source when you need the newest release, how to verify the install, and the one-time configuration every new install needs.
A quick way to find out whether Git is already installed is to open a terminal and ask for its version:
git --version
git version 2.43.0If you see a version number, Git is installed and you can skip ahead to configuring your identity. If you get command not found (or Windows prompts you to install developer tools), pick your operating system below.

How to Install Git on Mac
There are three common ways to install Git on macOS: the official Git for Mac installer, Homebrew, and MacPorts. Homebrew is the most popular for developers because it also keeps Git up to date with brew upgrade. The Apple Command Line Tools also ship a Git build — running git --version on a fresh Mac will offer to install them.
Mac Installer
This is the simplest way of installing Git on Mac. Here are the steps to follow:
- Download the latest Git for Mac installer.
- Open the downloaded package and follow the prompts to finish installing.
- Open the Terminal and run
git --versionto verify that the installation was successful:
git --version
git version 2.43.0Once Git is on your machine, set your identity so your commits are attributed correctly.
Homebrew
If you have Homebrew installed, this is the easiest path to keep up to date:
- Open your terminal and install Git with Homebrew:
Installing Git via Homebrew
brew install git- Verify the installation:
Install Git with Homebrew
git --version
git version 2.43.0Later, upgrade to the newest release at any time with brew upgrade git.
MacPorts
Follow these instructions to install Git with MacPorts:
- Update MacPorts:
Install Git with MacPorts
sudo port selfupdate- Search for the most recent Git ports and their variants:
Search Git ports and variants
port search git
port variants git- Install Git together with bash completion, the macOS keychain helper, and the docs:
Installing Git with macOS keychain helper
sudo port install git +bash_completion +credential_osxkeychain +docThe +credential_osxkeychain variant lets Git store your remote credentials in the macOS Keychain so you are not prompted for a password on every push.
How to Install Git on Windows
The recommended package is Git for Windows, which bundles the Git command line, Git Bash (a Unix-style shell), and an optional GUI.
- Download the most recent Git for Windows installer.
- Run the installer. The Setup wizard offers several choices — the defaults are sensible. Two worth noting:
- Default editor: choose the editor you already use (VS Code, Notepad, Vim, …) for commit messages.
- PATH environment: "Git from the command line and also from 3rd-party software" lets you run
gitfrom both Command Prompt/PowerShell and Git Bash.
- After installation, open Git Bash (or PowerShell) and verify:
git --version
git version 2.43.0.windows.1How to Install Git on Linux
On Linux, install Git through your distribution's package manager. The package is almost always named git.
Debian / Ubuntu ( apt-get )
Debian, Ubuntu, and their derivatives use APT. Update the package index first so you get the latest available version:
Install Git on Debian/Ubuntu
sudo apt-get update
sudo apt-get install gitThen verify the installation:
git --version
git --version
git version 2.43.0Fedora (dnf/yum)
Git packages are available via dnf. (Note: yum is deprecated in modern Fedora.)
- Install Git using dnf:
Install Git via dnf
sudo dnf install git- Verify the installation:
Check git version
git --version
git version 2.43.0Other distributions follow the same idea with their own package manager — for example sudo pacman -S git on Arch, or sudo zypper install git on openSUSE.
How to Install Git From Source on Linux
Distribution packages can lag behind the latest Git release. Building from source is the way to get the newest features the moment they ship — at the cost of installing build dependencies and recompiling on each update. You need libraries such as curl, zlib, openssl, expat, and gettext. On systems with dnf/yum or apt-get, install the dependencies first:
Dependencies on Fedora/RHEL (dnf/yum)
sudo yum install curl-devel expat-devel gettext-devel \
openssl-devel zlib-devel perl-devel asciidoc xmltoDependencies on Debian/Ubuntu (apt-get)
sudo apt-get install libcurl4-openssl-dev libexpat1-dev gettext \
libz-dev libssl-devTo build Git's documentation in other formats (man pages, HTML, info), add these dependencies as well:
Install Git and add documentation formats
sudo dnf install asciidoc xmlto docbook2X
sudo apt-get install asciidoc xmlto docbook2xNext, download a release tarball from the Git source releases, then compile and install:
Install Git, Compile and install
tar -zxf git-<version>.tar.gz
cd git-<version>
make prefix=/usr/local all
sudo make prefix=/usr/local installAfter installation, verify that Git is in your PATH by running git --version. If the command is not found, add /usr/local/bin to your PATH environment variable.
If you already have a Git build available, you can fetch the latest source directly instead of downloading a tarball:
Fetching source code
git clone https://github.com/git/git.gitConfigure Git After Installing
A fresh Git install does not know who you are. Before your first commit, set your name and email — Git records these on every commit you make. The --global flag stores them once for your user account so you do not repeat this in every repository:
Set your Git identity
git config --global user.name "Bob Smith"
git config --global user.email "[email protected]"It is also common to set your default branch name and preferred editor:
Common one-time settings
git config --global init.defaultBranch main
git config --global core.editor "code --wait"Check what is currently configured at any time:
List your configuration
git config --listFor a full tour of these settings and where Git stores them, see Git Config.
Verify the Installation
After installing on any platform, confirm Git is on your PATH:
git --version
git version 2.43.0If you see command not found, the install directory is not on your PATH. On a source build the binary is usually in /usr/local/bin — add it to PATH and restart your terminal. The exact version number you see depends on what shipped with your installer or package, so it may differ from the examples above.
Next Steps
With Git installed and configured, you are ready to start working with repositories:
- Git Repository — what a repository is and how Git tracks your project.
- git init — create a brand-new repository.
- git clone — copy an existing repository to your machine.
- Generate an SSH Key — connect securely to remotes like GitHub without typing a password.