Skip to main content

Quick Installation

Choose your operating system to get started:

Linux

Use your distribution’s package manager

macOS

Install via Homebrew or Xcode tools

Windows

Download the official installer

Installation by Platform

Debian/Ubuntu

sudo apt-get update
sudo apt-get install git

Fedora/RHEL/CentOS

sudo dnf install git
# Or on older versions:
sudo yum install git

Arch Linux

sudo pacman -S git

openSUSE

sudo zypper install git
On Linux, you may also need to install documentation packages separately (git-doc, git-man) if you want local manual pages.
brew install git

Using Xcode Command Line Tools

xcode-select --install
This installs a version of Git along with other development tools. However, it may not be the latest version.

Using MacPorts

sudo port install git
The Homebrew version is typically more up-to-date than the Xcode version.

Official Git for Windows

  1. Download the installer from git-scm.com/download/win
  2. Run the installer with default options
  3. Git Bash will be available from the Start menu

Using Chocolatey

choco install git

Using Winget

winget install --id Git.Git -e --source winget
Git for Windows includes Git Bash, which provides a Unix-like terminal environment on Windows.

Building from Source

For the latest features or if you want to contribute to Git development, you can build from source.

Prerequisites

Git requires these dependencies:
1

Essential Dependencies

Required for all builds:
  • zlib - Compression library (Git won’t build without it)
  • gcc or another C compiler
  • make - Build tool
# Debian/Ubuntu
sudo apt-get install build-essential zlib1g-dev

# Fedora/RHEL
sudo dnf install gcc make zlib-devel
2

Optional but Recommended

  • libcurl (version 7.61.0+) - For HTTP/HTTPS operations
  • expat - For git-http-push
  • Perl (version 5.26.0+) - For git-send-email, git-svn
  • Python (version 2.7+) - For git-p4
  • ssh - For remote operations
# Debian/Ubuntu
sudo apt-get install libcurl4-openssl-dev libexpat1-dev \
  gettext libssl-dev perl python3

# Fedora/RHEL
sudo dnf install curl-devel expat-devel gettext-devel \
  openssl-devel perl-devel python3
3

Documentation Tools (Optional)

Only needed if you want to build documentation:
  • asciidoc (version 8.4.1+) or Asciidoctor (version 1.5+)
  • xmlto - For man pages
  • docbook-xsl (version 1.74+)
# Debian/Ubuntu
sudo apt-get install asciidoc xmlto docbook-xsl

# Fedora/RHEL
sudo dnf install asciidoc xmlto docbook-style-xsl

Standard Build

The most common installation method:
# Clone the Git repository
git clone https://github.com/git/git.git
cd git

# Build and install to ~/bin/
make
make install
The prefix determines where Git will be installed. Common values are /usr, /usr/local, or your home directory. If you change the prefix between make all and make install, the installation will fail because paths are encoded during the build.

Build Configuration

You can customize the build by:
  1. Command line variables:
    make prefix=/usr/local NO_GETTEXT=YesPlease
    
  2. config.mak file:
    # Create config.mak in the source directory
    echo "prefix = /usr/local" > config.mak
    echo "NO_PERL = YesPlease" >> config.mak
    make
    
  • NO_CURL=YesPlease - Build without HTTP/HTTPS support
  • NO_EXPAT=YesPlease - Build without git-http-push
  • NO_PERL=YesPlease - Build without Perl scripts
  • NO_PYTHON=YesPlease - Build without Python scripts
  • NO_TCLTK=YesPlease - Build without gitk and git-gui
  • NO_GETTEXT=YesPlease - Disable localization (English only)
See the beginning of the Makefile for a complete list of variables.

Profile-Optimized Build

For better performance (useful for distribution packagers):
# Full test suite profile (slower build)
make prefix=/usr profile
sudo make prefix=/usr PROFILE=BUILD install

# Or faster benchmark-only profile
make prefix=/usr profile-fast
sudo make prefix=/usr PROFILE=BUILD install

# Or install to home directory
make profile-install
Profile-optimized builds take much longer because Git must be built twice. ccache must be disabled, and the test suite runs using only a single CPU. This also generates additional compiler warnings.

Testing Before Installing

You can test Git without installing it:
# After running 'make', use the wrapper scripts
./bin-wrappers/git status
./bin-wrappers/git log

# Or add to your PATH temporarily
export PATH="$(pwd)/bin-wrappers:$PATH"
git --version
Running from bin-wrappers is less efficient than an installed Git because it requires an extra fork+exec for every Git subcommand.

Verify Installation

After installation, verify Git is working:
1

Check Version

git --version
Should output something like: git version 2.45.0
2

Check Installation Path

which git
Shows where the git executable is installed
3

Test Basic Commands

git help
git help tutorial
Should display help information

Initial Configuration

Before using Git, set your identity:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
This information is embedded in every commit you make. Use the --global flag to set it once for your user account.
Optionally configure your default editor and initial branch name:
# Set your preferred text editor
git config --global core.editor "vim"

# Set default branch name for new repositories
git config --global init.defaultBranch main

Platform-Specific Notes

Perl Library Path

On some Linux distributions, Perl libraries may not be installed where you expect:
# Custom perllibdir for system package compatibility
make prefix=/usr perllibdir=/usr/share/perl5 install

Name Conflicts

Ancient versions of GNU Interactive Tools (pre-4.9.2) installed a program called “git” that conflicts with Git. Versions 4.9.2+ renamed to “gnuit”. If you have issues, check if another git executable exists or build GNU Interactive Tools with --disable-transition.

Troubleshooting

The git binary may not be in your PATH. Check your installation location and add it:
# Add to ~/.bashrc or ~/.zshrc
export PATH="/usr/local/bin:$PATH"
Install the required development packages for your distribution. Check the error message to identify which library is missing, then install the corresponding -dev or -devel package.
If installing to system directories like /usr, you need root privileges:
sudo make install

Next Steps

Now that Git is installed, you’re ready to start using it:

Quick Start

Make your first commit in minutes

Tutorial

Learn Git fundamentals step by step