GitInstall Git on macOS

Install Git on macOS

On macOS you have several good options. The right one depends on whether you already use Homebrew, want the very latest Git, or prefer the easiest possible path.

Check if Git is already installed

Bash
git --version

If macOS sees you typing git for the first time, it will pop up a dialog offering to install the Xcode Command Line Tools. Accepting that gives you Apple’s build of Git — perfectly usable, usually one or two versions behind upstream.

Option 1 — Homebrew (recommended)

Homebrew is the most popular macOS package manager. Installing Git through Homebrew gives you the latest version and makes updates trivial.

Install Homebrew (only if you don't have it)

Bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install Git

Bash
brew install git

Verify it picked up the Homebrew version:

Bash
which git
# /opt/homebrew/bin/git   (Apple Silicon)
# /usr/local/bin/git       (Intel Macs)

git --version
# git version 2.43.0
If `which git` still says /usr/bin/git
That is Apple’s built-in Git. Your shell PATH is finding it before the Homebrew one. Add Homebrew to the front of your PATH:
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
Then open a new terminal.
Option 2 — Xcode Command Line Tools

If you do not want a package manager, just type git in Terminal. macOS will offer to install the Command Line Tools. Click Install, wait a few minutes, and you have Git.

Or trigger it manually

Bash
xcode-select --install

This installs Apple’s Git plus a bunch of other developer tools (clang, make, etc.). The Git version may lag a release or two behind, which is rarely a problem.

Option 3 — Official installer

Download a .pkg from https://git-scm.com/download/mac. Open it, drag through the install wizard, done. This is fine for non-technical users who just want Git without a package manager.

Option 4 — MacPorts

If you use MacPorts instead of Homebrew:

Bash
sudo port install git
First-time configuration

Tell Git who you are

Bash
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main

# Useful defaults
git config --global core.editor "code --wait"   # VS Code
git config --global pull.rebase false
git config --global core.autocrlf input         # convert CRLF to LF on commit
Verify

Bash
git --version
git config --global user.name
git config --global user.email
Updating Git
  • Homebrew: brew update && brew upgrade git

  • Command Line Tools: install macOS updates from System Settings → General → Software Update; Git updates come along for the ride.

  • Official installer: re-download the latest .pkg from git-scm.com.

Terminal apps
  • Terminal.app — built into macOS. Perfectly fine.

  • iTerm2 — popular free upgrade with split panes, search, scripting. Highly recommended.

  • Warp / Hyper / Kitty / Alacritty — modern alternatives. Any of them work fine with Git.

Apple Silicon vs Intel

Both architectures work identically. The only practical difference is the Homebrew install path:

  • Apple Silicon (M1/M2/M3/M4): /opt/homebrew

  • Intel Macs: /usr/local

Common problems
  • xcrun: error: invalid active developer path — macOS lost track of the Xcode Command Line Tools. Run xcode-select --install to repair.

  • Old Git from Apple is taking precedence over Homebrew Git — adjust your PATH so Homebrew comes first (see Note above).

  • git: command not found on first use — the install script needs a new terminal session, or Homebrew’s shell init has not been added to ~/.zshrc.

  • Permissions errors — never use sudo with git for normal work. If you see permission denied on a folder, it is probably a directory permission issue, not a Git issue.

Tip
macOS has shipped with `zsh` as the default shell since Catalina. Anything written for Bash in Git tutorials usually works in Zsh unchanged. Both shells run the same `git` binary.