GitInstalling Git

Installing Git

Before you can use Git you need to install it. Git is available for every major operating system, totally free. The installation adds a git command to your terminal — that one binary is the entire program. There is no separate “Git server” to install for normal use.

Check if Git is already installed

Many systems ship with Git pre-installed. Before downloading anything, check:

Check your current Git version

Bash
git --version
# Example output:
# git version 2.43.0

If you see a version number, Git is installed. If you see command not found or git is not recognised, you need to install it.

Tip
You want a reasonably recent Git — version 2.30 or newer. Older versions are missing useful features like `git switch` and `git restore`. If your system Git is ancient, upgrade.
Quick installation by OS
Windows

The official installer is at https://git-scm.com/download/win. Download and run it. The defaults are sensible — just keep clicking Next. The installer also bundles Git Bash, a Unix-like terminal that runs the same commands documented in every Git tutorial.

Or, if you have winget (Windows 10/11):

Install Git with winget

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

The easiest method is Homebrew (recommended):

Install Git on macOS

Bash
# Install Homebrew first if you don't have it
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Then install Git
brew install git

Alternatively, macOS includes Apple’s build of Git via Xcode Command Line Tools. The first time you run git in a fresh terminal, macOS will offer to install them.

Linux

Use your distribution’s package manager:

Install Git on Linux

Bash
# Debian / Ubuntu
sudo apt update
sudo apt install git

# Fedora
sudo dnf install git

# Arch
sudo pacman -S git

# Alpine
apk add git
Verify the installation

After installing, open a new terminal and run:

Bash
git --version

You should see something like git version 2.43.0. If you do, Git is ready to use.

First-time setup (you only do this once per machine)

Git tags every commit with your name and email. Tell it who you are:

One-time configuration

Bash
git config --global user.name "Your Name"
git config --global user.email "you@example.com"

# Pick a default branch name for new repos (most teams use 'main')
git config --global init.defaultBranch main

# Set your preferred editor (used for commit messages)
git config --global core.editor "code --wait"   # VS Code
# git config --global core.editor "nano"        # nano
# git config --global core.editor "vim"         # vim

# Optional: nicer log output
git config --global pull.rebase false             # explicit merge on pull
git config --global core.autocrlf input          # macOS/Linux
# git config --global core.autocrlf true         # Windows

You can check your config any time with:

Bash
git config --global --list
What --global means
`--global` writes to `~/.gitconfig` and applies to every repo on your machine. Without it, the setting only applies to the current repo (stored in `.git/config`). You can also use `--system` (for /etc) but that is rare.
Updating Git
  • Windows: run the new installer; it replaces the old one.

  • macOS (Homebrew): brew update && brew upgrade git

  • Linux: use your package manager — sudo apt upgrade git, etc.

Uninstalling Git

If for some reason you need to remove Git:

  • Windows: Apps & Features → uninstall Git.

  • macOS (Homebrew): brew uninstall git

  • Linux: sudo apt remove git (or equivalent).

Uninstalling Git does not delete your existing repositories or their history — those live in .git folders inside your project folders. Reinstalling Git will pick them right up.

Tip
After installing, try the rest of this tutorial alongside a real terminal. The commands are the same on Windows (use Git Bash), macOS, and Linux.