Git Course 0%

Install Git on macOS, Windows, Linux

Beginner Git CLI VS Code UI IntelliJ UI ≈ 10 min

Before this lesson

What you will learn

  • The recommended way to install Git on macOS, Windows and Linux
  • Which options in the Windows installer matter and what to pick
  • How to confirm that Git is installed and reachable

After this lesson you can

  • Git 2.23 or newer is installed on my computer and git --version works

Why this matters

Git is a program on your computer; nothing in this course works without it. Installing takes a few minutes, but the Windows installer asks a dozen questions, and the answers decide how pleasant the next months will be. This lesson picks them for you.

Which version you need

Anything from 2.23 onwards: that is when git switch and git restore arrived, and the course uses them throughout. Current releases are in the 2.4x–2.5x range; any recent installer is fine. Check what you have first; many computers already have Git.

macOS

  1. Open Terminal (+Space, type Terminal).
  2. Run git --version. If Git is installed, it prints a version and you are done. If macOS opens a dialog offering to install the command line developer tools, click Install: that installs Apple's build of Git (usually a few versions behind, but fine).
  3. If you prefer the newest Git, and you have Homebrew: brew install git. Homebrew's Git takes precedence in the terminal once installed. Both can coexist.
Terminal
$ git --version
git version 2.50.1 (Apple Git-155)

The (Apple Git-…) suffix means the command line tools build; a Homebrew build prints only the version number.

Windows

Install Git for Windows from gitforwindows.org. It brings Git, Git Bash (the terminal this course uses), and a credential manager. Alternatively, in PowerShell: winget install --id Git.Git -e --source winget, which installs the same package with default options.

The installer has many pages. Keep the defaults except where this table says otherwise:

Installer page Choose Why
Select components Defaults; make sure Git Bash Here and Git GUI Here are ticked if offered Right-click a folder → open Git Bash there
Default editor Use Visual Studio Code as Git's default editor (if you use VS Code); otherwise Notepad++ or Nano. Avoid Vim unless you know it The editor opens for commit messages when you forget -m
Initial branch name Override the default branch name for new repositoriesmain Matches GitLab, GitHub and this course
PATH environment Git from the command line and also from 3rd-party software (the recommended middle option) VS Code and IntelliJ find Git
SSH executable Use bundled OpenSSH Works with the SSH lessons in Section 8
HTTPS transport OpenSSL library Default
Line ending conversions Checkout Windows-style, commit Unix-style (the first option) Files look right on Windows, and colleagues on macOS and Linux see clean diffs
Terminal emulator MinTTY The Git Bash window
git pull behaviour Fast-forward or merge (default) Simplest for beginners
Credential helper Git Credential Manager Stores your token securely after the first push
Extra options Enable file system caching Faster

After installing, open Git Bash from the Start menu and run git --version.

Linux

Use your distribution's package manager, then check the version; most distributions ship a recent Git.

Terminal
$ sudo apt update && sudo apt install git      # Debian, Ubuntu, Mint
$ sudo dnf install git                          # Fedora, RHEL
$ sudo pacman -S git                            # Arch

If the packaged version is older than 2.23 (rare), Ubuntu users can add the git-core PPA; otherwise ask your administrator.

Confirm from your tools

Terminal
$ git --version
git version 2.50.1

Any 2.23 or higher is good. command not found means Git is not installed or the terminal cannot find it; on Windows, make sure you opened Git Bash (or a new PowerShell window after installing).

Common mistakes

  • Installing GitHub Desktop and thinking Git is installed. It bundles a private Git for its own use; the terminal may still say command not found. Install Git itself.
  • On Windows, opening cmd after installing. Use Git Bash; it is what the course assumes.
  • Skipping the default-branch page. New repositories will be created with master; fixable later with git config --global init.defaultBranch main (lesson 3.3).
  • Vim opening unexpectedly when a commit message is missing. Press Esc, type :q!, press Enter to leave without committing, then set a friendlier editor in lesson 3.3.

Try it yourself

Goal: confirm Git is installed and recent enough.

  1. Open your terminal (Git Bash on Windows).
  2. Run git --version.
  3. Open VS Code or IntelliJ and confirm the Source Control view or the Git settings page finds it.

Expected result: a version of 2.23 or higher in the terminal and no "Git not found" message in your IDE.

Show solution

If the version is lower than 2.23, update: on macOS brew upgrade git (or rerun the developer tools installer), on Windows rerun the Git for Windows installer, on Linux update through the package manager. If the IDE cannot find Git while the terminal can, lesson 3.6 fixes the path.

Check yourself

1. On Windows, which terminal does this course use?
2. Why does the course require Git 2.23 or newer?
3. In the Windows installer, the safest choice for line endings when working with colleagues on macOS and Linux is…

Key terms

Git Terminal