The previous lesson explained why Git exists and introduced Ana, Bruno and Carla, the team who will build task-manager. Before Ana can turn her folder into a repository she needs something elementary: Git installed. This lesson covers installation on the three usual operating systems — Linux, macOS and Windows — how to verify it worked, how to consult the built-in help, and how to keep Git up to date. It also clears up what Git Bash is, what graphical clients are, and why the whole course works on the command line.

This is a thoroughly hands-on lesson: by the end you will have a working Git on your machine and know how to check it.

Contents

  1. Before you start: check whether you already have Git
  2. Installing on Linux
  3. Installing on macOS
  4. Installing on Windows
  5. Verifying the installation
  6. The built-in help: git help
  7. Git Bash, terminals and graphical clients
  8. Why the command line in this course
  9. How to update Git

  1. Before you start: check whether you already have Git

Many systems ship Git preinstalled, or other tools have installed it. Before downloading anything, open a terminal and run:

git --version

There are two possible outcomes:

git version 2.51.0

Something like this means you already have Git. Check that the version is reasonably recent (2.30 or above is enough for the whole course; 2.40 or above is ideal) and skip to section 5.

bash: git: command not found

If you see this — or 'git' is not recognized... on Windows — Git is either not installed or not on the PATH. Follow the section for your system.

A note on versions. Git is extraordinarily stable and backwards compatible: almost everything you learn will still work the same way ten years from now. Even so, some modern conveniences (such as git switch and git restore, covered in modules 2 and 3) need Git 2.23 or above, and certain sensible defaults arrived in 2.28. It is worth not staying on an old version.

  1. Installing on Linux

On Linux, Git comes from your distribution's package manager. That is the recommended route: the system handles dependencies and updates for you.

Debian, Ubuntu, Linux Mint (apt)

sudo apt update
sudo apt install git

Breaking the commands down:

  • sudo runs the command with administrator privileges, which installing system-wide software requires. It will ask for your password.
  • apt update refreshes the list of available packages and their versions. It does not upgrade any program; it only brings the catalogue up to date. Skipping this step is the most frequent reason for ending up with an old version.
  • apt install git downloads and installs the git package and its dependencies.

Fedora, RHEL, CentOS Stream, Rocky Linux (dnf)

sudo dnf install git

On older systems that have yum instead of dnf, the equivalent command is sudo yum install git.

Other distributions

Distribution Command
Arch Linux, Manjaro sudo pacman -S git
openSUSE sudo zypper install git
Alpine Linux sudo apk add git
Gentoo sudo emerge --ask dev-vcs/git

Useful companion packages

The basic git package includes everything essential, but some distributions split out extras worth having:

# Debian/Ubuntu: minimal graphical interface (gitk and git gui) plus e-mail utilities
sudo apt install gitk git-gui git-email
  • gitk is a graphical history viewer that ships with Git.
  • git-gui is a minimal graphical client for staging and committing changes.
  • git-email enables sending patches by e-mail, as projects like the Linux kernel do.

None of them is essential for this course.

Installing the latest version on Ubuntu

Stable distributions tend to lag a little. If you need the most recent release, there is an official repository maintained by the Git team:

sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git

add-apt-repository adds an extra package source; from then on apt treats it like any other and will offer Git updates automatically.

  1. Installing on macOS

On macOS there are three routes. The order below is also the order of preference.

Option A: Homebrew (recommended)

Homebrew is the de facto package manager on macOS. If you don't have it yet:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

This command downloads the official installation script and runs it. Broken down: curl downloads the URL (-fsSL means "fail on errors, silent mode, show errors, follow redirects") and $( ) hands the result to bash to execute.

Once Homebrew is available:

brew install git

Homebrew installs Git into /opt/homebrew/bin/git (Apple Silicon) or /usr/local/bin/git (Intel), paths that take precedence over the system version in the PATH. That way you always have an up-to-date version.

Option B: Xcode Command Line Tools

macOS includes a version of Git inside Apple's developer tools. Install them with:

xcode-select --install

A system window will appear asking for confirmation. They are also triggered automatically the first time you type git in a terminal without having them installed.

The upside: nothing else is needed. The downside: the version tends to trail by several months or years, and it only moves with system updates.

Option C: the official binary installer

There are .dmg installers at git-scm.com/download/mac. It is a valid option if you would rather avoid package managers, but updating is then down to you.

macOS at a glance

Method Version Updates Requirements
Homebrew The latest brew upgrade git Installing Homebrew
Command Line Tools Behind With the system None
.dmg installer Recent at install time Manual None

  1. Installing on Windows

Windows does not include Git, so you have to install it. There are three routes.

Option A: the official "Git for Windows" installer (recommended)

Download the installer from git-scm.com/download/win and run it. The wizard asks quite a few questions; these are the ones that matter, with the recommended answers:

Wizard screen Recommended choice Why
Select Components Tick "Git Bash Here" and "Git GUI Here" Adds quick access from the Explorer context menu
Default editor used by Git Visual Studio Code (or whichever you use) Saves you from being trapped in Vim with no idea how to quit; covered in 01-06
Initial branch name "Override... " → main The modern main branch name; it can also be set later (01-06)
Adjusting your PATH "Git from the command line and also from 3rd-party software" Lets you use git from PowerShell and CMD, not just Git Bash
Choosing the SSH executable "Use bundled OpenSSH" Enough for the whole course
HTTPS transport backend "Use the native Windows Secure Channel library" Honours the corporate certificates installed in Windows
Line ending conversions "Checkout Windows-style, commit Unix-style" Sets core.autocrlf=true; explained in 01-06
Terminal emulator "Use MinTTY" A better terminal than the Windows console for Git Bash
Credential helper "Git Credential Manager" Stores your credentials; detailed in 01-06 and in module 4

If you hesitate on a screen not listed here, leave the default: they are sensible choices and almost all of them can be changed later with git config.

Option B: Windows package managers

If you prefer an unattended installation:

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

Or with Chocolatey:

choco install git

winget comes bundled with modern Windows 10 and 11. The -e flag forces an exact match on the identifier so you don't install a similarly named package by mistake.

Option C: WSL (Windows Subsystem for Linux)

WSL runs a real Linux distribution inside Windows. If you develop with Unix-world tools (Node.js, Python, Docker), it usually gives the best experience.

wsl --install

Once inside the distribution (Ubuntu by default), Git installs exactly as on any Linux:

sudo apt update
sudo apt install git

An important warning about WSL. The Windows Git and the WSL Git are two separate installations, with independent configurations. On top of that, working from WSL on files stored on the Windows disk (/mnt/c/...) is noticeably slow and causes trouble with permissions and line endings. The recommendation is to keep your repositories inside the Linux file system (~/projects/...) and use only the WSL Git.

Windows at a glance

Method Terminal Performance Recommended for
Git for Windows Git Bash, PowerShell, CMD Good General use, starting from scratch
winget / Chocolatey Same as above Good Automated installations
WSL Linux terminal Excellent (inside WSL) Development with Unix tooling

  1. Verifying the installation

Whatever your system, close the terminal and open it again (so it picks up the PATH changes) and run:

git --version

The expected output, with whatever number applies:

git version 2.51.0

Some further useful checks:

# Where the executable lives
which git          # Linux, macOS, Git Bash
where git          # PowerShell / CMD on Windows
# Path to Git's auxiliary files (internal commands, templates)
git --exec-path
# List of every available subcommand
git help -a

That last command prints a long list. You don't need to understand it; it is there to confirm the installation is complete rather than truncated.

If git --version still fails

Symptom Likely cause Fix
command not found right after installing The terminal is holding the old PATH Close the terminal and open it again
'git' is not recognized on Windows The PATH option wasn't ticked in the installer Re-run the installer and pick "Git from the command line..."
An older version than the one installed Two installations exist and the system one wins which -a git to see them all; adjust the PATH order
Permission denied on Linux You tried to install without sudo Try again with sudo

  1. The built-in help: git help

Git ships its full documentation inside the program itself. Learning to consult it is worth more than memorising options.

# General help: the most common commands grouped by purpose
git help
# The full manual for one command
git help config

This command opens the manual page for git config. On Linux and macOS it appears in the less pager: navigate with the arrow keys or space, search with /word and quit with q. On Windows, git help opens the HTML version in your browser by default.

There are three equivalent ways to ask for a command's manual:

git help config
git config --help
man git-config     # Unix systems only

For a quick look, without opening the full manual, there is the options summary:

git config -h

The lowercase -h prints a handful of lines with the syntax and the main options straight into the terminal. It is the one you will reach for most from day to day.

Command What it shows When to use it
git help An index of common commands To get your bearings
git help <command> The full manual To understand something thoroughly
git <command> -h A short summary of options A quick check
git help -a Every subcommand To explore
git help -g The bundled conceptual guides Background reading

Try git help -g: Git includes topic guides such as gittutorial, giteveryday and gitglossary, which you read with git help giteveryday.

  1. Git Bash, terminals and graphical clients

What Git Bash is

Git Bash is a Windows-only component that comes with the official installer. It is not Git: it is a terminal emulator bundled with a Bash interpreter and a set of Unix utilities (ls, grep, ssh, curl, vim…) compiled for Windows.

It exists for a practical reason: Git's documentation, the examples you find online and hooks (scripts that run automatically, module 6) all assume a Unix environment. Git Bash provides that environment without leaving Windows.

Terminal on Windows Does git work? Unix commands (ls, grep)?
Git Bash Yes Yes
PowerShell Yes, if the PATH option was ticked Partly, with different aliases
CMD Yes, if the PATH option was ticked No
WSL Yes, the Linux Git Yes, natively

If you are on Windows, use Git Bash to follow the course: the commands in the lessons will work exactly as written. On Linux and macOS, the system terminal is already enough.

What graphical clients are

A graphical client (GUI) is an application with windows and buttons that runs Git commands underneath. The best known ones:

Client Platforms Notes
gitk / git gui All Ship with Git; austere but always available
GitHub Desktop Windows, macOS Very simple, GitHub-oriented
Sourcetree Windows, macOS Free, comprehensive, a little heavy
GitKraken All Beautifully polished history visualisation
Fork Windows, macOS Light and fast
Editor integration All VS Code, IntelliJ, Vim and others bundle Git support

Graphical clients are useful, above all for reviewing differences and navigating the history. There is nothing wrong with using them, and many professionals combine the terminal for doing and a GUI for looking.

  1. Why the command line in this course

This course uses the command line exclusively, for concrete reasons:

  1. It is the only complete interface. Every graphical client implements a subset of Git. Sooner or later you will need something your GUI doesn't offer, and then you will have to open the terminal anyway.
  2. It is universal. A continuous integration server, a remote machine over SSH or a colleague's laptop doesn't have your GUI installed, but they all have git in the terminal.
  3. It teaches the model, not the tool. Buttons hide what is happening. Typing git commit after git add forces you to grasp that there are two steps, and that understanding is what lets you solve problems.
  4. The documentation and the answers are written as commands. Any manual, issue or answer you find will be expressed in commands, not in "click here".
  5. It is faster once learned. And it automates: commands chain together in scripts, graphical interfaces don't.

A practical tip. Learn on the terminal first, then add whichever graphical client you fancy. The reverse order leaves gaps that are hard to close.

  1. How to update Git

Keeping Git current brings security fixes, performance improvements and new commands. The update commands by system:

# Debian / Ubuntu
sudo apt update && sudo apt upgrade git

# Fedora
sudo dnf upgrade git

# Arch Linux
sudo pacman -Syu git

# macOS with Homebrew
brew update && brew upgrade git

# Windows with winget
winget upgrade --id Git.Git -e

On Windows, modern Git versions also bundle an update command of their own:

git update-git-for-windows

This command checks whether a newer version of Git for Windows exists, downloads it and launches the installer. It only exists on Windows.

To find out which version is the latest release, check git-scm.com or run your package manager's update command: if there is nothing new, it will tell you.

Updating breaks nothing. Existing repositories keep working exactly the same after an update: the on-disk format has been backwards compatible for over a decade. Updating is safe.

Common Mistakes and Tips

  • Not closing the terminal after installing. The PATH is read when the terminal session starts. If you have just installed Git and git --version fails, close it and open it again before giving up on anything.
  • Forgetting apt update before apt install. Without refreshing the catalogue you can end up installing a very old version, or get a package-not-found error.
  • On Windows, not ticking the PATH option. If you pick "Use Git from Git Bash only", git won't work in PowerShell or in VS Code. The fix is to re-run the installer.
  • Mixing the Windows Git and the WSL Git on the same folder. It causes permission clashes, mismatched line endings and crossed configurations. Pick one and keep your repositories in its native file system.
  • Installing Git from a hand-unzipped .zip. It works, but the system has no record of it and updating becomes a problem. Always use the package manager or the official installer.
  • Tip: set your editor during the Windows installation. Leave the default and you will land in Vim the first time Git asks you to write a message. It can be changed later (lesson 01-06), but it is an unpleasant surprise.
  • Tip: install gitk on Linux as well. It is a history viewer that helps a lot in visualising what you are learning, and it doesn't get in the way of using the terminal.

Exercises

Exercise 1: Auditing your installation

Run the commands needed to answer these five questions about your machine, and note down both the command you used and the result:

  1. Which version of Git do you have installed?
  2. Where does the executable live?
  3. Is there more than one Git installation on your PATH?
  4. How many subcommands does your installation offer?
  5. Which conceptual guides does the documentation include?

Exercise 2: Exploring the help

Without searching online, use only Git's built-in help to find out:

  1. What the --global option of git config does.
  2. Which Git command "shows the working tree status" (look for it in the list of common commands).
  3. The name of the bundled guide that summarises everyday Git use.

State which command you ran in each case.

Exercise 3: An installation plan for the team

The task-manager team is a mixed bunch: Ana works on Ubuntu, Bruno on a MacBook with Apple Silicon and Carla on Windows 11. Write brief instructions for each of them covering: (a) the installation command or method, (b) how to verify it worked and (c) one warning specific to their platform.


Solutions

Solution to Exercise 1

# 1. Installed version
git --version
# → git version 2.51.0 (the number will vary)

# 2. Path to the executable
which git            # Linux, macOS, Git Bash
where git            # PowerShell or CMD
# → /usr/bin/git, /opt/homebrew/bin/git, C:\Program Files\Git\cmd\git.exe...

# 3. Every installation on the PATH
which -a git         # the -a option shows all matches, not just the first
# More than one line means you have several installations: the first one wins

# 4. Number of subcommands
git help -a | wc -l
# wc -l counts lines; the exact number varies by version and installation

# 5. Bundled guides
git help -g
# → gitcore-tutorial, giteveryday, gitglossary, gitworkflows, gittutorial...

Solution to Exercise 2

  1. --global in git config:
git help config
# Search inside the manual by typing /--global and pressing Enter

The documentation states that --global writes to the user's configuration file (~/.gitconfig), which applies to all of that user's repositories. That is the level we will use in lesson 01-05.

  1. The status command:
git help

In the common commands section, status appears with the description "Show the working tree status". The command is git status and we will put it to work in module 2.

  1. The everyday guide:
git help -g

The guide is giteveryday, which you read with git help giteveryday. It summarises the twenty commands that cover 95 % of real-world use.

Solution to Exercise 3

Ana — Ubuntu

sudo apt update
sudo apt install git
git --version

Warning: the version in Ubuntu's official repositories may trail by several releases. If she needs the latest, she should add the ppa:git-core/ppa PPA before installing.

Bruno — macOS (Apple Silicon)

brew install git
git --version
which git    # should return /opt/homebrew/bin/git

Warning: macOS ships its own Git at /usr/bin/git via the Command Line Tools. If which git returns that path instead of the Homebrew one, the PATH is in the wrong order and he will keep using the old version.

Carla — Windows 11

Download the installer from git-scm.com/download/win and, during the wizard, choose "Git from the command line and also from 3rd-party software" on the PATH screen, main as the initial branch name, and her usual editor.

# Open Git Bash and check
git --version

Warning: if she doesn't tick the PATH option, git will work only inside Git Bash and will fail in PowerShell and in her editor. She should also follow the course from Git Bash so that the commands in the lessons work literally as written.

Conclusion

You now have Git installed and verified. On Linux it comes from the distribution's package manager; on macOS the most practical route is Homebrew (with the Command Line Tools as a no-prerequisites alternative); and on Windows it is the official Git for Windows installer, which additionally provides Git Bash, the terminal environment to follow the course in. The basic check is always the same — git --version — and the full documentation lives inside the program itself, reachable with git help <command> or, for quick questions, git <command> -h.

We have also justified the course's methodological decision: we will work on the command line because it is the complete, universal interface, and the one that teaches Git's model instead of hiding it. Graphical clients are an excellent complement, not a substitute.

Having the tool is not enough: you need to understand its vocabulary. In the next lesson, Basic Git Terminology, we will build the glossary that everything else rests on — repository, staging area, commit, HEAD, branch, remote — and look at the diagram of the three states any file in Git passes through.

Mastering Git: From Beginner to Advanced

Module 1: Introduction to Git

Module 2: Basic Git Operations

Module 3: Branching and Merging

Module 4: Working with Remote Repositories

Module 5: Advanced Git Operations

Module 6: Git Tools and Techniques

Module 7: Collaboration and Workflow Strategies

Module 8: Git Best Practices and Tips

Module 9: Troubleshooting and Debugging

Module 10: Git in the Real World

© Copyright 2026. All rights reserved