Install Git on macOS, Windows, Linux
Beginner Git CLI VS Code UI IntelliJ UI
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
- Open Terminal (⌘+Space, type
Terminal). - 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). - 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.
$ git --versiongit 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 repositories → main |
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.
$ sudo apt update && sudo apt install git # Debian, Ubuntu, Mint
$ sudo dnf install git # Fedora, RHEL
$ sudo pacman -S git # ArchIf 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
$ git --versiongit version 2.50.1Any 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).
Open VS Code, open any folder, and open the Source Control view (Ctrl+Shift+G / ⌃⇧G). If it offers Initialize Repository or shows changes, VS Code found Git. If it says "Git not found", restart VS Code after installing; if the message stays, lesson 3.6 sets the path by hand.
Open IntelliJ IDEA, then Settings → Version Control → Git. The Path to Git executable field shows the Git IntelliJ found; click Test. A version number means success. If it is empty or the test fails, lesson 3.6 explains how to point it at the right file.
Nothing to install for GitLab itself: it is a website. What you will need there is an account (lesson 9.1) and, before your first push, a token or SSH key (Section 8).
Likewise, GitHub needs an account (lesson 10.1) and a token or SSH key, not an installation. The optional GitHub Desktop app and the gh command-line tool are separate downloads that this course does not require.
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
cmdafter installing. Use Git Bash; it is what the course assumes. - Skipping the default-branch page. New repositories will be created with
master; fixable later withgit 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.
- Open your terminal (Git Bash on Windows).
- Run
git --version. - 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.