Ad – 728×90
📖 Introduction

Installing & Configuring Git – Setup Guide for Windows, Mac, Linux

Before you can run your first Git command, you need to install Git on your machine and configure your identity. The installation process is straightforward on all three major operating systems, and Git configuration only needs to be done once per machine. In this lesson you will install Git on your OS, verify it works, set your name and email (which are attached to every commit you make), and apply the three essential global settings that every developer should configure before their first commit.

⏱️ 15 min read 🎯 Beginner 📅 Updated 2026

Installing Git on Windows

There are two good ways to install Git on Windows. The recommended modern approach is using winget (Windows Package Manager, built into Windows 10 and 11). Alternatively, download the installer from git-scm.com.

Option 1 — winget (Recommended)

PowerShell / Command Prompt
# Install Git using Windows Package Manager
winget install Git.Git

This installs Git for Windows, which includes Git Bash (a Unix-like terminal for Windows), Git GUI, and the Git command-line tools. After installation, restart any open terminals so the git command is available in your PATH.

Option 2 — Installer from git-scm.com

Download the installer from git-scm.com/download/win and run it. During installation, the recommended settings for most developers are:

  • Default editor — choose your preferred editor (VS Code is a great choice)
  • Default branch name — select "Override to main" (not "master")
  • PATH environment — "Git from the command line and also from 3rd-party software"
  • Line endings — "Checkout Windows-style, commit Unix-style line endings"
ℹ️
WSL users

If you use Windows Subsystem for Linux (WSL), install Git inside your Linux distribution using the Linux instructions below. Git installed in Windows and Git installed in WSL are separate installations and should be configured independently.

Installing Git on macOS

macOS comes with a version of Git pre-installed via Xcode Command Line Tools, but it is often outdated. The recommended approach is to install a current version via Homebrew.

Option 1 — Homebrew (Recommended)

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

# Then install Git
brew install git

Option 2 — Xcode Command Line Tools

Bash
# This installs Apple's bundled Git (may be older version)
xcode-select --install

A dialog box will appear asking to install the Command Line Developer Tools. Click "Install". Once complete, Git will be available at /usr/bin/git. If you already ran brew install git, the Homebrew version at /usr/local/bin/git takes precedence.

Installing Git on Linux

Git is available in the package manager of every major Linux distribution. Use the command for your distro:

Bash
# Debian / Ubuntu / Linux Mint / Pop!_OS
sudo apt update && sudo apt install git

# Fedora / RHEL 9+ / AlmaLinux
sudo dnf install git

# Arch Linux / Manjaro
sudo pacman -S git

# openSUSE
sudo zypper install git
Ad – 336×280

Verifying Your Installation

After installation, open a new terminal (or restart your existing one) and run:

Bash
git --version
▶ Expected output
git version 2.44.0

You should see a version number of 2.30 or higher (the exact version depends on when you install). If you see "command not found", Git is not in your PATH — on Windows, try opening Git Bash instead; on Mac/Linux, try restarting your terminal.

Configuring Git – Why It Matters

Before making your first commit, you must configure your identity. Git records your name and email address in every single commit you create. This is important because:

  • Your commits on GitHub/GitLab show your name and link to your profile
  • In team projects, everyone can see who made which changes and contact the right person
  • When reviewing history, git blame shows who wrote each line
  • CI/CD systems and code review tools use commit authorship for notifications and assignments
⚠️
Configure this before your first commit

If you make commits without configuring your identity, Git will use a default or system value that may be wrong. Correcting the author on past commits is possible but tedious. Set your name and email now — it takes 30 seconds.

Setting Up Your Global Configuration

The --global flag saves the setting to your user-level config file (~/.gitconfig), which applies to all repositories on your machine. You only need to do this once per machine.

Bash
# Set your name — appears in every commit you make
git config --global user.name "Your Name"

# Set your email — use the same email as your GitHub account
git config --global user.email "you@example.com"

# Set the default branch name to "main" (modern standard)
git config --global init.defaultBranch main

# Set your preferred text editor (examples below)
git config --global core.editor "code --wait"    # VS Code
git config --global core.editor "nano"           # Nano (simple)
git config --global core.editor "vim"            # Vim
ℹ️
Why set init.defaultBranch to main?

Historically, Git's default branch was named master. The industry shifted to main around 2020–2021, and GitHub now uses main by default for new repositories. Setting init.defaultBranch main makes your local git init create a main branch instead of master, keeping your local repos consistent with GitHub.

Viewing Your Configuration

To see all active configuration settings and where each one is set (global vs local), run:

Bash
# List all active config settings with their source files
git config --list --show-origin
▶ Example output
file:/home/you/.gitconfig   user.name=Your Name
file:/home/you/.gitconfig   user.email=you@example.com
file:/home/you/.gitconfig   init.defaultbranch=main
file:/home/you/.gitconfig   core.editor=code --wait
Per-project configuration

You can override global settings for a specific project by running git config without the --global flag inside that project's directory. This creates a .git/config file that applies only to that repository. Useful when you have a work computer and want different name/email for personal vs work projects.

📋 Summary

  • Windows: install with winget install Git.Git or the git-scm.com installer.
  • macOS: install with brew install git or xcode-select --install.
  • Linux: install with sudo apt install git, sudo dnf install git, etc.
  • Verify installation with git --version — expect 2.30 or higher.
  • Configure your identity with git config --global user.name and user.email before your first commit.
  • Set git config --global init.defaultBranch main to use the modern default branch name.
  • View all settings with git config --list --show-origin.

FAQ

Is the Git config permanent? Can I change it later? +

Yes, the global config is permanent across sessions (it is stored in ~/.gitconfig on Mac/Linux or C:\Users\YourName\.gitconfig on Windows), but you can change it at any time by running the same git config --global commands with new values. Changes only affect future commits — existing commits retain whatever author information was set at the time they were created.

What if I have multiple GitHub accounts (work and personal)? +

Set your personal email globally with git config --global user.email "personal@email.com", then override it in each work project's directory with git config user.email "work@company.com" (no --global flag). This sets a per-repository config that overrides the global one. For SSH authentication with multiple accounts, you will need to configure multiple SSH keys and a custom ~/.ssh/config file — covered in the SSH Keys lesson.

Do I need to reinstall Git to upgrade it? +

No — you use the same method you used to install it. On Windows: winget upgrade Git.Git. On macOS with Homebrew: brew upgrade git. On Linux: sudo apt upgrade git or the equivalent for your package manager. Your ~/.gitconfig settings are preserved across upgrades. It is good practice to update Git periodically to get security patches and new features.

What editor should I use with Git? +

Git uses your configured editor when you run commands that require you to write a message (like git commit without -m, or git rebase -i). VS Code (code --wait) is a great choice because it is visual and familiar. If you are comfortable in the terminal, nano is beginner-friendly (simple save/exit commands shown at the bottom). Avoid vim unless you already know it — the learning curve is steep for beginners who just want to write a commit message.