Read Anthropic’s case study about Graphite Reviewer

How to resolve the error "git is not recognized" on Mac

Greg Foster
Greg Foster
Graphite software engineer


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


When working on a Mac, encountering the error "git is not recognized," "git command not found," or a similar message typically indicates that Git is either not installed on your machine, or it is not properly configured in the system's PATH. This guide provides step-by-step instructions to help you resolve these errors, ensuring that Git functions correctly on your machine.

Before diving into troubleshooting, let's first check if Git is already installed on your Mac.

  • Open your terminal: You can find Terminal in the Applications > Utilities folder or search for it using Spotlight.

  • Check Git version: Type the following command and press Enter:

    git --version

If Git is installed, you'll see the installed version number:

git version example

If you receive an error message like "command not found," proceed with the following steps.


If Git is not installed, there are several ways to install it on macOS:

  • Option 1: Install Xcode command line tools:

    • Xcode Command Line Tools is a suite of developer tools for macOS that also includes Git. You can install it by running:

      xcode-select --install

    • Click “Install” in the software update popup window that appears.

    You can also install Xcode from the mac app store.

  • Option 2: Install Git with Homebrew:

    • If you have Homebrew installed, you can easily install Git by running:

      brew install git

      If you don't have Homebrew, you can install it from the official Homebrew website.

  • Option 3: Install Git with MacPorts

    • If you have MacPorts installed you can install Git by running:

    sudo port install git

    If you don’t already have MacPorts installed you can install it from the official MacPorts site.

After installation, you need to ensure that the Git executable is correctly added to your system's PATH.

  • Check PATH for Git:

    • In Terminal, type:

      echo $PATH

    • Verify that the path to the Git binary is included in the output. The exact path depends on how Git was installed (e.g., if installed via Homebrew, it might be /usr/local/bin/git).

  • Add Git to PATH (if necessary):

    • If you are unable to locate Git in your path, you'll need to add it. Open your .bash_profile or .zshrc file in a text editor, depending on whether you are using Bash or Zsh as your shell, usually located in your /Users/<your-username> home directory.

    • Add the following line to the end of the file to amend the path:

      export PATH="/usr/local/bin:$PATH"

    • Save the file and restart your terminal session for the changes to take effect.

After installation and adding Git to your PATH, close and reopen Terminal, then type git --version to verify that Git is now recognized and working correctly.

  • Git still not recognized: If Git is still not recognized, restart your computer to ensure all changes are applied.

  • Permission issues: If you encounter permission errors during installation, you may need to prepend sudo to the install commands, which will prompt you to enter your macOS user password.

For further reading please see the official git documentation on installation.

Git inspired
Graphite's CLI and VS Code extension make working with Git effortless.
Learn more

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2