How to install Git on macOS
Installing Git on macOS is crucial for development workflows, enabling version control, collaboration, and deployment processes across all types of software projects. As the creator of CoreUI, a widely used open-source UI library, I’ve helped countless macOS developers set up Git for contributing to our repositories, managing component libraries, and maintaining enterprise applications. From my expertise, the most efficient approach is to use Homebrew package manager. This method provides automatic updates, easy management, and the latest Git version while integrating seamlessly with the macOS development environment.
Use Homebrew package manager for the easiest Git installation and management on macOS.
# Method 1: Using Homebrew (Recommended)
# First install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Git with Homebrew
brew install git
# Update Git to latest version
brew upgrade git
# Method 2: Xcode Command Line Tools (Built-in)
# Install Xcode Command Line Tools (includes Git)
xcode-select --install
# Method 3: Official Git installer
# Download from https://git-scm.com/download/mac
# Run the .dmg file and follow installation steps
# Method 4: Using MacPorts
sudo port install git
# Verify installation
git --version
# Output: git version 2.x.x
# Check which Git is being used
which git
# /opt/homebrew/bin/git (Homebrew on Apple Silicon)
# /usr/local/bin/git (Homebrew on Intel)
# /usr/bin/git (System/Xcode version)
# Configure Git after installation
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
# Optional: Configure editor
git config --global core.editor "code --wait" # For VS Code
git config --global core.editor "nano" # For nano
# Check configuration
git config --list
Homebrew provides the most up-to-date Git version and easiest maintenance through brew upgrade
. Xcode Command Line Tools include a system version of Git that’s sufficient for basic use but may be older. The official installer gives you control over the specific version but requires manual updates. If you already have multiple Git installations, check which git
to see which version is active and adjust your PATH if needed.
Best Practice Note:
This is the same installation method we recommend for CoreUI contributors and macOS development teams. Use Homebrew for automatic updates and latest features, configure your preferred editor for commit messages, set up proper authentication with SSH keys or credential helpers, and ensure your PATH prioritizes the Homebrew Git over system Git for consistency.