Installing Git

Before you can follow along you need Git on your computer and a terminal to type commands into. This lesson covers Windows, macOS and Linux, and how to check that the installation worked.

Check whether Git is already installed

Open a terminal (see below for where to find it) and run:

$
git --version
Output
git version 2.39.5

If you see a version number, Git is installed. Any 2.x version will work for this course, though a recent one (2.40 or later) gives you the friendliest messages. If you see "command not found" or "'git' is not recognized", install it as shown below.

Windows

  1. Download the installer from git-scm.com (it is called Git for Windows).
  2. Run it. The defaults are sensible; two screens worth reading:
    • Default editor — pick one you know, such as Visual Studio Code or Notepad, instead of Vim.
    • Initial branch name — choose "Override" and type main.
  3. When it finishes, open Git Bash from the Start menu.

Git Bash is a terminal that understands the same commands as macOS and Linux (ls, cd, cat…), so every example in this course works there unchanged. Git also works in PowerShell and Windows Terminal. If you use the winget package manager, winget install --id Git.Git does the same job.

macOS

Open Terminal (Applications → Utilities, or press Cmd+Space and type "Terminal") and run git --version. If Git is missing, macOS offers to install the Command Line Developer Tools, which include it — accept, and wait for the download.

Apple's version usually trails the latest release. To get the newest Git, install it with Homebrew:

$
brew install git

Linux

Use your distribution's package manager:

$
# Debian, Ubuntu, Linux Mint
sudo apt update
sudo apt install git

# Fedora
sudo dnf install git

# Arch
sudo pacman -S git

Terminals, GUIs and editors

This course teaches Git through the command line. That's where every feature is available, error messages are clearest, and what you learn applies everywhere. There are also graphical tools:

  • Code editors — Visual Studio Code, JetBrains IDEs and others have Git built in: a panel listing changed files, buttons to stage and commit, and coloured markers in the margin for changed lines.
  • Desktop apps — GitHub Desktop, GitKraken, Sourcetree, Fork and others visualise history and branches.

They all run the same Git underneath, so they work fine alongside the terminal. Once you understand the commands, the buttons make sense too.

Checking the result

After installing, close the terminal and open a new one, so it picks up the new program, then run git --version again. You're ready for the next lesson, where you tell Git who you are.

About the examples: the output in this course comes from running every command with Git 2.39. Newer versions occasionally word a hint or message slightly differently, but the commands and their behaviour are the same.

Try it yourself

Install Git, open a new terminal and run git --version. Then run git help to see a list of the most common commands — by the end of this course you'll know all of them.