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)
# 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"
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)
# 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
# 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:
# 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
Verifying Your Installation
After installation, open a new terminal (or restart your existing one) and run:
git --version
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 blameshows who wrote each line - CI/CD systems and code review tools use commit authorship for notifications and assignments
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.
# 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
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:
# List all active config settings with their source files
git config --list --show-origin
file:/home/you/.gitconfig user.email=you@example.com
file:/home/you/.gitconfig init.defaultbranch=main
file:/home/you/.gitconfig core.editor=code --wait
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.Gitor the git-scm.com installer. - macOS: install with
brew install gitorxcode-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.nameanduser.emailbefore your first commit. - Set
git config --global init.defaultBranch mainto use the modern default branch name. - View all settings with
git config --list --show-origin.
FAQ
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.
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.
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.
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.