“git: command not found” – How to Install Git on Any OS (Windows, macOS, Linux)
If you’ve ever tried running git in your terminal or command prompt only to be greeted with the error:
git: command not foundYou’re not alone. This is one of the most common issues new developers or users face when working with version control for the first time. The good news? This is easily fixable.
In this article, you’ll learn:
- What this error means
- Why it happens
- How to install Git correctly on Windows, macOS, and Linux
- How to verify that Git is installed
- Optional: Setting up Git after installation
Let’s fix the problem.
💡 What Does “git: command not found” Mean?
This error simply means your operating system doesn’t recognize the git command.
In technical terms, Git isn’t installed or it’s not added to your system’s PATH environment variable — a list of directories your system uses to find executable files.
🛠️ How to Fix It: Installing Git by OS
Below are step-by-step instructions for installing Git on Windows, macOS, and Linux.
🪟 Windows: Installing Git
✅ Step 1: Download Git for Windows
- Go to the official Git website:
👉 https://git-scm.com/download/win - The download should start automatically.
- Once downloaded, double-click the
.exeinstaller.
✅ Step 2: Run the Installer
During installation, you’ll be prompted to choose settings. Here are the recommended options:
- Choosing the default editor: Select your preferred editor (e.g., VS Code, Notepad++).
- Adjusting your PATH environment: Choose
“Git from the command line and also from 3rd-party software.”
→ This adds Git to your systemPATH.
Continue clicking Next and finally click Install.
✅ Step 3: Verify Installation
After installation:
- Open Command Prompt or PowerShell.
- Type:
git --version - You should see something like:
git version 2.42.0.windows.1
Congrats! Git is now installed.
🍏 macOS: Installing Git
You have a couple of options for installing Git on macOS: via Xcode Command Line Tools, Homebrew, or the official Git installer.
Option 1: Install Git via Xcode Command Line Tools (Recommended for Beginners)
✅ Step 1: Open Terminal and Type:
git --versionIf Git is not installed, macOS will prompt:
“The ‘git’ command requires the command line developer tools. Would you like to install the tools now?”
Click Install and wait for the download to complete.
✅ Step 2: Confirm Installation
After installation, run:
git --versionYou should see:
git version 2.xx.x (Apple Git)Option 2: Install Git via Homebrew (For Advanced Users)
If you already use Homebrew:
brew install gitOption 3: Use the Git Installer
- Download from https://git-scm.com/download/mac
- Run the
.dmgfile and follow instructions.
🐧 Linux: Installing Git
Depending on your Linux distribution, the package manager will vary. Here’s how to install Git on the major distros.
✅ Ubuntu / Debian
Open terminal and run:
sudo apt update
sudo apt install git✅ Fedora
sudo dnf install git✅ Arch Linux
sudo pacman -S git✅ Verify Git Installation
Run:
git --versionExpected output:
git version 2.xx.x✅ Post-Installation: Setting Up Git (Recommended)
Once Git is installed, it’s a good idea to configure it with your user name and email. These details will be associated with your commits.
🔧 Step 1: Set Your Username
git config --global user.name "Your Name"🔧 Step 2: Set Your Email
git config --global user.email "you@example.com"🔧 Step 3: Confirm Configuration
git config --listYou should see output like:
user.name=Your Name
user.email=you@example.com🧪 Still Getting the Error?
If you’ve installed Git but still get the git: command not found error, here are a few troubleshooting tips:
1. Check Your PATH Variable
If Git isn’t in your system PATH, your terminal can’t find it. To check:
On Windows:
Open Command Prompt and run:
echo %PATH%Make sure you see a path that looks like:
C:\Program Files\Git\cmdIf not, you may need to manually add it via:
Control Panel → System → Advanced system settings → Environment Variables → Edit
Path
On macOS/Linux:
Run:
echo $PATHEnsure the Git binary path is included, e.g., /usr/bin or /usr/local/bin.
🔄 Updating Git (Optional)
If Git is already installed but outdated, you can upgrade:
On Windows:
Download and install the latest version from https://git-scm.com
On macOS with Homebrew:
brew upgrade gitOn Ubuntu:
sudo apt update
sudo apt upgrade git🤔 Final Thoughts
The git: command not found error is a simple fix that usually just means Git isn’t installed or isn’t correctly set up in your environment.
By following the OS-specific instructions above, you’ll have Git up and running in no time — whether you’re on Windows, macOS, or Linux.
Now that Git is installed, you’re ready to:
- Clone repositories
- Commit changes
- Push to GitHub
- Collaborate on code with others
Welcome to the world of version control!
📌 Quick Commands Summary
| OS | Install Command / Method |
|---|---|
| Windows | Installer from git-scm.com |
| macOS | xcode-select --install or brew install git |
| Ubuntu | sudo apt install git |
| Fedora | sudo dnf install git |
| Arch | sudo pacman -S git |

