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
- Before you start: check whether you already have Git
- Installing on Linux
- Installing on macOS
- Installing on Windows
- Verifying the installation
- The built-in help:
git help - Git Bash, terminals and graphical clients
- Why the command line in this course
- How to update Git
- 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:
There are two possible outcomes:
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.
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 switchandgit 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.
- 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)
Breaking the commands down:
sudoruns the command with administrator privileges, which installing system-wide software requires. It will ask for your password.apt updaterefreshes 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 gitdownloads and installs thegitpackage and its dependencies.
Fedora, RHEL, CentOS Stream, Rocky Linux (dnf)
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-emailgitkis a graphical history viewer that ships with Git.git-guiis a minimal graphical client for staging and committing changes.git-emailenables 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:
add-apt-repository adds an extra package source; from then on apt treats it like any other and will offer Git updates automatically.
- 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:
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:
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:
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 |
- 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:
Or with Chocolatey:
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.
Once inside the distribution (Ubuntu by default), Git installs exactly as on any Linux:
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 |
- Verifying the installation
Whatever your system, close the terminal and open it again (so it picks up the PATH changes) and run:
The expected output, with whatever number applies:
Some further useful checks:
# Where the executable lives
which git # Linux, macOS, Git Bash
where git # PowerShell / CMD on WindowsThat 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 |
- The built-in help:
git help
git helpGit ships its full documentation inside the program itself. Learning to consult it is worth more than memorising options.
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:
For a quick look, without opening the full manual, there is the options summary:
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.
- 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.
- Why the command line in this course
This course uses the command line exclusively, for concrete reasons:
- 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.
- 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
gitin the terminal. - It teaches the model, not the tool. Buttons hide what is happening. Typing
git commitaftergit addforces you to grasp that there are two steps, and that understanding is what lets you solve problems. - 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".
- 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.
- 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 -eOn Windows, modern Git versions also bundle an update command of their own:
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
PATHis read when the terminal session starts. If you have just installed Git andgit --versionfails, close it and open it again before giving up on anything. - Forgetting
apt updatebeforeapt 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
PATHoption. If you pick "Use Git from Git Bash only",gitwon'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
gitkon 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:
- Which version of Git do you have installed?
- Where does the executable live?
- Is there more than one Git installation on your
PATH? - How many subcommands does your installation offer?
- 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:
- What the
--globaloption ofgit configdoes. - Which Git command "shows the working tree status" (look for it in the list of common commands).
- 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
--globalingit config:
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.
- The status command:
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.
- The everyday guide:
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
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)
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.
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
- What Is Git?
- Installing Git
- Basic Git Terminology
- The Git Data Model
- Configuring Git
- Initial Configuration
Module 2: Basic Git Operations
- Creating a Repository
- Cloning a Repository
- The Basic Git Workflow
- Staging and Committing Changes
- Inspecting Changes with git diff
- Viewing Commit History
Module 3: Branching and Merging
- Understanding Branches
- Creating and Switching Branches
- Merging Branches
- Merge Strategies
- Resolving Merge Conflicts
- Branch Management
Module 4: Working with Remote Repositories
- Understanding Remote Repositories
- Adding a Remote Repository
- Authenticating with Remote Repositories
- Fetching and Pulling Changes
- Pushing Changes
- Tracking Branches
Module 5: Advanced Git Operations
Module 6: Git Tools and Techniques
- Using Git Hooks
- Git Bisect
- Git Blame
- Git Log and Aliases
- Git Submodules
- Multiple Working Copies with git worktree
Module 7: Collaboration and Workflow Strategies
- Forks and Pull Requests
- Code Reviews with Git
- The Git Flow Workflow
- GitHub Flow
- Trunk Based Development
- Continuous Integration with Git
Module 8: Git Best Practices and Tips
- Writing Good Commit Messages
- Keeping a Clean History
- Ignoring Files with .gitignore
- File Attributes with .gitattributes
- Security Best Practices
- Performance Tips
Module 9: Troubleshooting and Debugging
- Common Git Problems
- Undoing Changes
- Resolving Divergence with the Remote
- Recovering Lost Commits
- Dealing with Corrupted Repositories
- Advanced Debugging Techniques
