How-to

How to install Git on Windows, macOS and Linux

Updated: · Skillaria.Top

To install Git on Windows, download the installer from the official site git-scm.com and run the wizard, keeping the recommended settings. On macOS, run brew install git or xcode-select --install; on Linux, sudo apt install git (Debian, Ubuntu) or sudo dnf install git (Fedora). Verify the installation with git --version.

Quick answer: how to install Git on any system

SystemCommand or method
WindowsInstaller from git-scm.com or winget install --id Git.Git -e --source winget
macOSbrew install git or xcode-select --install
Ubuntu, Debiansudo apt update && sudo apt install git
Fedora, RHELsudo dnf install git
Arch Linuxsudo pacman -S git
openSUSEsudo zypper install git

After installing on any system, open a terminal and run git --version. If you get something like git version 2.x.y back, Git is installed and ready to configure.

Where to download Git: the official git-scm site

The only official source is git-scm.com, under Downloads. The site detects your system and suggests the right option. Don't download a Git installer from third-party "software directory" sites: they sometimes host outdated versions and installers bundled with adware.

For Windows, git-scm.com points to the Git for Windows build (the git-for-windows project on GitHub). For macOS and Linux, the site doesn't offer a separate installer; instead it shows package manager commands. That's normal and actually more convenient: updates then arrive along with your system updates.

Installing Git on Windows

Step 1. Download the installer

Open git-scm.com, go to Downloads → Windows and pick "64-bit Git for Windows Setup." The portable version is only needed if you don't have admin rights or want to carry Git on a USB stick. There's a separate ARM64 build for ARM-based machines.

Step 2. Run the setup wizard

The installer asks a lot of questions, which tends to scare beginners. You can keep the defaults almost everywhere, but a few screens are worth understanding:

  • Select Components — keep Git Bash Here and Git GUI Here (File Explorer context menu items), Git LFS and the file associations.
  • Choosing the default editor — the default is Vim, which beginners can't figure out how to exit. Pick Visual Studio Code, Notepad++ or Nano if you have them. This is the editor that opens when Git asks for a commit message.
  • Adjusting the name of the initial branch — choose "Override the default branch name for new repositories" and enter main. That way new repositories match GitHub.
  • Adjusting your PATH environment — keep the recommended "Git from the command line and also from 3rd-party software." Then the git command works in Git Bash, PowerShell and the VS Code terminal.
  • Choosing the SSH executable — Use bundled OpenSSH.
  • Choosing HTTPS transport backend — OpenSSL is fine for most users; on a corporate network with its own certificates, Windows Secure Channel is the better choice.
  • Configuring the line ending conversions — "Checkout Windows-style, commit Unix-style line endings." That's core.autocrlf=true: LF line endings go into the repository, while your working files use CRLF.
  • Configuring the terminal emulator — MinTTY (the Git Bash terminal).
  • Credential helper — Git Credential Manager. It remembers your GitHub sign-in via the browser, so you don't have to enter a token by hand.

Leave the remaining screens (git pull behavior, file system caching, experimental options) as they are.

Step 3. Verify the installation

Open Git Bash from the Start menu, or PowerShell, and run:

$ git --version
git version 2.47.1.windows.1

Your number will differ — what matters is that the command responds. If PowerShell says "git is not recognized as an internal or external command," close and reopen the terminal: the PATH variable is only picked up by new windows.

Installing Git on Windows with winget

Windows 10 and 11 ship with the winget package manager. Install with a single PowerShell command:

winget install --id Git.Git -e --source winget

This installs with default settings, without the wizard's choices. You can easily change the editor and branch name later with git config.

Installing Git on macOS

Option 1. Apple's Command Line Tools

On macOS, Git is often "half there" already: the first time you run git, the system offers to install the Command Line Tools. You can also trigger this explicitly:

xcode-select --install

The downside: Apple ships its own build, which is updated along with the Xcode tools and usually lags behind the current release.

Option 2. Homebrew (recommended)

If you have the Homebrew package manager, this is the most convenient route:

brew install git
git --version
which git

which git should show /opt/homebrew/bin/git on Apple Silicon Macs or /usr/local/bin/git on Intel. If it shows /usr/bin/git, the system Git comes first in your PATH — open a new terminal or make sure the Homebrew init line is in ~/.zprofile.

Installing Git on Linux

On Linux, Git is installed from your distribution's repositories. Many distros already ship it, so check git --version first.

Ubuntu, Debian, Linux Mint

sudo apt update
sudo apt install git

On Ubuntu LTS releases, the package can lag noticeably behind the latest release. To get a current version, add the Git team's official PPA:

sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git

Fedora, RHEL, Rocky, AlmaLinux

sudo dnf install git

Arch, Manjaro

sudo pacman -S git

Alpine (for example, in a Docker image)

apk add --no-cache git

In a Debian-based Dockerfile, use apt-get instead of apt and clear the cache: RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*.

How to check your Git version

git --version (or git version) prints the installed version. For troubleshooting, the extended build info is useful:

$ git version --build-options
git version 2.43.0
cpu: x86_64
sizeof-long: 8
...

Why the version matters at all: some commands are relatively recent. For example, git switch and git restore have existed since Git 2.23, and the init.defaultBranch setting since 2.28. If a tutorial doesn't work for you, compare versions first.

How to update Git

How you update Git depends on how it was installed:

Installation methodUpdate command
Git for Windows (installer)git update-git-for-windows or run a fresh installer over the old one
wingetwinget upgrade --id Git.Git
Homebrewbrew upgrade git
aptsudo apt update && sudo apt install --only-upgrade git
dnfsudo dnf upgrade git
pacmansudo pacman -Syu

Updating doesn't touch your settings (~/.gitconfig) or repositories. The Windows installer remembers your previous wizard answers, so you won't have to pick the options again.

What to do right after installing

Installing Git is only half the job. Git won't let you commit without a name and email, so do the minimum setup right away:

git config --global user.name "Jane Smith"
git config --global user.email "jane@example.com"
git config --global init.defaultBranch main
git config --global core.editor "code --wait"

The last line makes VS Code your commit message editor (the --wait flag is required, otherwise Git won't wait for the window to close). To check the result: git config --global --list.

Then test everything on a practice repository:

mkdir hello-git && cd hello-git
git init
echo "# Hello" > README.md
git add README.md
git commit -m "First commit"
git log --oneline

Common Git installation problems

"git: command not found" or "is not recognized as an internal command"

Git didn't make it into your PATH. On Windows, reinstall with the PATH option "Git from the command line and also from 3rd-party software" and open a new terminal. On Linux and macOS, check that the package is actually installed: which git.

VS Code doesn't detect Git

Restart VS Code after installing. If that doesn't help, set the path in the git.path setting, for example C:\Program Files\Git\cmd\git.exe.

macOS still shows an old version even though brew installed a new one

The system /usr/bin/git comes before Homebrew in your PATH. Run eval "$(/opt/homebrew/bin/brew shellenv)" and add that line to ~/.zprofile.

SSL errors when cloning on a corporate network

The network is intercepting certificates. On Windows, switch the backend: git config --global http.sslBackend schannel. Don't disable certificate verification (http.sslVerify false) — that opens the door to man-in-the-middle attacks.

Weird changes in every file right after cloning

That's line endings: LF files are turning into CRLF or vice versa. Check git config core.autocrlf: true is recommended on Windows, input on macOS and Linux. For a team, it's more reliable to pin the rules in the repository's .gitattributes file, for example with the line * text=auto.

Which installation method to choose

If you're just starting out on Windows, go with the official installer: it shows all the important options and installs Git Bash, Git Credential Manager and OpenSSH in one go. Experienced users tend to prefer winget — it's easy to include in a setup script for a new machine along with your other software.

On macOS, choose Homebrew if you plan to install other developer tools too: Node.js, Python, the Docker CLI. The Command Line Tools are enough if you only need Git occasionally. On Linux, the distro package is almost always enough; you only need the newer PPA version if you want commands or fixes your LTS build doesn't have.

Summary

Installing Git is easy: on Windows, use the official installer from git-scm.com or winget; on macOS, Homebrew; on Linux, your distro's package manager. Pay attention to three screens in the Windows wizard: the editor, the main branch name and PATH. After installing, check git --version, set your name and email, and you're ready for your first commit. Installation, terminal setup and handy aliases are covered in detail, hands-on, in the Git course.

FAQ

Do I need admin rights to install Git?

For the standard Windows installer, yes. Without them, you can use the portable version of Git for Windows, or install Git for the current user only if the wizard offers that option.

Does Git come with GitHub Desktop or VS Code?

VS Code doesn't include Git and uses the one installed on your system. GitHub Desktop bundles its own copy of Git, but it isn't available from the terminal, so it's better to install Git separately.

Can I have several Git versions on one computer?

Yes, but the one found first in PATH is the one that runs. You can check which one is active with which git (macOS, Linux) or where git (Windows).

How do I completely uninstall Git?

On Windows, via Apps & Features; on macOS, brew uninstall git; on Linux, sudo apt remove git or the equivalent. Your ~/.gitconfig settings file stays behind, and you can delete it manually.

Does Git work in WSL?

Yes, inside WSL you install Git as on any Linux system, via apt. It's a separate installation, independent of Git for Windows.

Learn this topic on video

This topic is covered in depth with practice in the course “Git from Scratch to Confident Developer”.

Go to course