On This Page
Install Git on Windows, macOS, and Linux
Quick answer: First check whether Git is already installed with git --version. If it is not, use the official Git for Windows installer, Apple’s Command Line Tools or Homebrew on macOS, or your Linux distribution’s package manager. Run git --version again when installation finishes. Installing Git makes the command-line tool available; it does not create a repository or sign you in to GitHub.
Check before installing
Open the terminal you plan to use and run:
git --version
If you see a result such as git version 2.x.x, Git is available in that terminal. You may already have Git through Xcode Command Line Tools on macOS, a Linux development image, or another developer tool. If the command is not found, follow the instructions for your operating system below.
Install Git on Windows
The official Git for Windows installer is the simplest route for most people. It installs Git and can include Git Bash, a terminal that provides a Unix-like command environment on Windows.
- Download the installer from Git for Windows.
- Run the setup wizard. The defaults are suitable for most users; review the editor and line-ending choices if you already have preferences.
- For the command-line tools to work from PowerShell, Command Prompt, and other programs, choose the installer option that allows Git to be used from the command line and third-party software.
- Finish setup, then open a new terminal window.
- Verify the installation:
git --version
If you chose to use Git Bash, you can also open Git Bash from the Start menu and run the same command there.
Install Git on Windows with winget
If you use Windows Package Manager, install Git from an elevated PowerShell window with:
winget install --id Git.Git -e --source winget
Close and reopen the terminal after the package manager finishes, then run git --version. The winget package installs the same Git for Windows build as the official installer, including Git Bash. If winget is unavailable, use the official installer above.
Git Bash download and what it includes
Git Bash is the Unix-like terminal bundled with the Git for Windows installer. It gives you bash, common Unix utilities, and the git command in one window. Download Git for Windows from git-scm.com/download/win; you do not need a separate Git Bash download. During setup, keep the default component that installs Git Bash, then launch it from the Start menu.
Install Git on macOS
Try the version check first:
git --version
If Git is missing, macOS may offer to install Apple’s Xcode Command Line Tools. You can also request that installer directly:
xcode-select --install
Follow the macOS prompt, then open a new Terminal window and check git --version again.
If you already use Homebrew, you can instead install its Git package:
brew install git
To see which copy your shell finds when more than one is installed, run:
which -a git
Install Git on Linux
Use the package manager for your distribution. These commands cover common distributions; you may need to replace sudo with your system’s administrator method.
Debian or Ubuntu
sudo apt update
sudo apt install git
Fedora
sudo dnf install git
Arch Linux
sudo pacman -S git
When the package manager finishes, verify the install:
git --version
Install Git inside WSL
If you use Windows Subsystem for Linux, install Git inside the Linux distribution rather than relying on the Windows executable. Open your WSL shell and run the command for that distribution, such as sudo apt install git on Ubuntu. This keeps file permissions, line endings, and credential helpers consistent with the Linux tools you run there.
For another distribution, follow its package instructions from the official Git Linux downloads page rather than copying a command for a different package manager.
Verify the executable and troubleshoot “command not found”
Run the version check in the same terminal or editor where you want to use Git:
git --version
To find the executable path, use command -v git on macOS or Linux, or where.exe git in PowerShell. If the command works in one terminal but not another, the two applications may have different PATH settings.
If Git was just installed but the command is still missing:
- Close and reopen the terminal so it reads the updated environment.
- On Windows, confirm the installer was configured to add Git to the command-line
PATH. The usual command-line folder isC:\Program Files\Git\cmd. - If you installed more than one copy, inspect the path result and choose the version you intend to use; avoid adding several competing Git folders to
PATHat random. - If needed, rerun the official installer and adjust its command-line integration option.
What to do after installation
Git is ready to run, but a few separate steps may still be needed:
- Set the name and email recorded on new commits with the Git configuration guide.
- Start a repository in a project folder with
git init, or download an existing project withgit clone.
Those steps are separate from installing the program. You do not need to create an account just to install Git or use it locally.
Official references
Test Your Knowledge
Loading quiz…