Installing Git
Introduction
Before you run git commit, Git must be installed and available on your PATH. This chapter covers installation on Windows, macOS, and Linux, plus verification steps so every later chapter can focus on version control—not environment errors.
Prerequisites
- What Is Git
- A terminal: PowerShell or Command Prompt (Windows), Terminal (macOS), or bash (Linux/WSL)
- Internet access to download installers or packages
What You Get After Install
| Component | Purpose |
|---|---|
git | Main command-line tool |
| Git Bash (Windows) | Unix-like shell bundled with Git for Windows |
| Documentation | git help <command> |
You do not need a GitHub account to install or use Git locally.
Install on Windows
Option A: Official Git for Windows (Recommended)
- Open https://git-scm.com/download/win
- Download the 64-bit installer (or 32-bit on older PCs)
- Run the installer—defaults are fine for learning:
- Git from the command line and also from 3rd-party software — adds
gitto PATH - Default branch name:
main - Line ending conversion: Checkout Windows-style, commit Unix-style is common on Windows
- Git from the command line and also from 3rd-party software — adds
- Close and reopen PowerShell or Git Bash
Typical install path:
C:\Program Files\Git\Option B: winget
winget install --id Git.Git -e --source wingetVerify on Windows
git --versionExpected: git version 2.x.x.windows.x
where.exe gitCode explanation:
git --versionconfirms the command workswhere.exe gitshows which executable runs if multiple installs exist
Tip
New Terminal After Install
PATH updates apply only in new terminal windows. Restart VS Code integrated terminal if it was open during install.
Install on macOS
Option A: Xcode Command Line Tools
xcode-select --installFollow the GUI prompt. Includes Git and other developer tools.
Option B: Homebrew
brew install gitHomebrew often provides a newer Git than the system bundle.
Verify on macOS
git --version
which gitInstall on Linux
Ubuntu / Debian
sudo apt update
sudo apt install -y gitFedora / RHEL / Rocky / Alma
sudo dnf install -y gitVerify on Linux
git --versionOn WSL2 Ubuntu, use the same apt commands—see Linux learning environment.
Minimum Version
Use Git 2.30+ for learning this track. Older distros may ship 2.25—still usable; upgrade via Homebrew or git-scm.com if features are missing.
git --versionGit Bash vs PowerShell vs CMD (Windows)
| Shell | Notes |
|---|---|
| Git Bash | Bash syntax; matches Linux examples closely |
| PowerShell | Native Windows; git commands identical |
| CMD | Works; prefer PowerShell or Git Bash |
This tutorial shows bash-style comments; translate # comments mentally in PowerShell.
Common Install Problems
| Problem | Fix |
|---|---|
git is not recognized | Reinstall with PATH option; open new terminal |
| Old version after upgrade | Check which git / where git; fix PATH order |
| Permission denied on Linux | Use sudo for package install only—not for git commit |
| Corporate proxy blocks download | IT mirror or portable Git zip |
Post-Install Checklist
-
git --versionprints 2.x -
git helpopens usage (or paginated help text) - Terminal restarted after install
- Ready for Git configuration
FAQ
Do I need GitHub Desktop?
No. This track teaches CLI Git. Desktop apps wrap the same commands.
Git vs GitHub CLI (gh)?
Separate tools—gh manages PRs and issues; install later if needed.
Install for all users on Windows?
Per-user install is fine for learning; admin install adds system-wide PATH.
WSL and Windows Git both installed?
Use Git inside WSL for Linux projects in WSL; use Windows Git for Windows-native folders—avoid mixing repos across boundaries without care.
How to uninstall?
Windows: Settings → Apps; macOS: brew uninstall git; Linux: apt remove git.
Is Git LFS included?
Optional separate install—covered in an advanced chapter.