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

ComponentPurpose
gitMain command-line tool
Git Bash (Windows)Unix-like shell bundled with Git for Windows
Documentationgit help <command>

You do not need a GitHub account to install or use Git locally.

Install on Windows

  1. Open https://git-scm.com/download/win
  2. Download the 64-bit installer (or 32-bit on older PCs)
  3. Run the installer—defaults are fine for learning:
    • Git from the command line and also from 3rd-party software — adds git to PATH
    • Default branch name: main
    • Line ending conversion: Checkout Windows-style, commit Unix-style is common on Windows
  4. Close and reopen PowerShell or Git Bash

Typical install path:

text
C:\Program Files\Git\

Option B: winget

powershell
winget install --id Git.Git -e --source winget

Verify on Windows

powershell
git --version

Expected: git version 2.x.x.windows.x

powershell
where.exe git

Code explanation:

  • git --version confirms the command works
  • where.exe git shows 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

bash
xcode-select --install

Follow the GUI prompt. Includes Git and other developer tools.

Option B: Homebrew

bash
brew install git

Homebrew often provides a newer Git than the system bundle.

Verify on macOS

bash
git --version
which git

Install on Linux

Ubuntu / Debian

bash
sudo apt update
sudo apt install -y git

Fedora / RHEL / Rocky / Alma

bash
sudo dnf install -y git

Verify on Linux

bash
git --version

On 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.

bash
git --version

Git Bash vs PowerShell vs CMD (Windows)

ShellNotes
Git BashBash syntax; matches Linux examples closely
PowerShellNative Windows; git commands identical
CMDWorks; prefer PowerShell or Git Bash

This tutorial shows bash-style comments; translate # comments mentally in PowerShell.

Common Install Problems

ProblemFix
git is not recognizedReinstall with PATH option; open new terminal
Old version after upgradeCheck which git / where git; fix PATH order
Permission denied on LinuxUse sudo for package install only—not for git commit
Corporate proxy blocks downloadIT mirror or portable Git zip

Post-Install Checklist

  • git --version prints 2.x
  • git help opens 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.