Git 1b 🧩 Installing Git
Git runs on every major operating system. The installation process differs by platform — Windows uses an installer with many options, Linux uses a package manager, and macOS ships Git with the developer tools. This chapter walks through each, plus verification, so you can confirm Git is ready before you start using it.
1. Installing Git on Windows
On Windows, the recommended way to install Git is Git for Windows — an installer that includes Git Bash, a Unix-like terminal that makes following Linux/macOS tutorials straightforward. Most Git documentation assumes a Unix-style shell, so Git Bash removes a lot of friction.
Download the installer:
Go to the official site — https://git-scm.com/download/win — and the download starts automatically. If it doesn’t, click 64-bit Git for Windows Setup (or 32-bit if your system needs it).
Run the installer:
Locate the downloaded file, double-click it, and if User Account Control prompts you, click Yes to allow the installer to make changes.
Walk through the wizard:
The installer asks a series of configuration questions. Most defaults are fine, but a few matter.
| Screen | Recommended choice | Why |
|---|---|---|
| License | Accept GNU GPL | Required to proceed |
| Destination | Default path | Any location works |
| Components | Include “Git Bash Here” and “Git GUI Here” | Adds right-click context menu |
| Start Menu folder | Default | Cosmetic |
| PATH environment | Git from the command line and also from 3rd-party software | Git works everywhere |
| SSH executable | Use bundled OpenSSH | Simplest, safest |
| HTTPS backend | Use the OpenSSL library | Preferred default |
| Line endings | Checkout Windows-style, commit Unix-style | Best for cross-platform work |
| Terminal | Use MinTTY | Better than the default console |
git pull behavior | Default (fast-forward or merge) | Standard behavior |
| Credential helper | Git Credential Manager Core | Saves credentials securely |
| Extra options | Enable file system caching | Faster performance |
Two of these are worth highlighting:
PATH environment. The recommended option — Git from the command line and also from 3rd-party software — puts Git on your system PATH. That means git works in Command Prompt, PowerShell, and Git Bash. The alternative — Use Git and optional Unix tools from the Command Prompt — can override Windows tools like find and sort, which usually causes more problems than it solves.
Line endings. Windows uses CRLF (\r\n); Linux and macOS use LF (\n). The recommended option — Checkout Windows-style, commit Unix-style — converts automatically: files are stored as LF in the repository, but checked out as CRLF on Windows. This avoids a whole class of “every line changed” diffs when collaborating across platforms.
Complete the installation:
When the wizard finishes, you can check Launch Git Bash and View Release Notes. Click Finish.
Verify:
Open Command Prompt or PowerShell and run:
git --version
You should see the installed version. Right-click on any folder and check for Git Bash Here and Git GUI Here in the context menu. Clicking Git Bash Here opens a Unix-style terminal in that directory.
Why Git Bash matters: Most Git tutorials, examples, and Stack Overflow answers use Unix-style commands —
ls,cd,touch,rm. Git Bash gives you those commands on Windows, so you can copy-paste examples and they just work.
2. Installing Git on Linux
On Linux, install Git through your distribution’s package manager. It’s the easiest and most reliable path — no manual downloads, automatic updates.
Update the package lists first. This refreshes the package manager’s index so it sees the latest versions.
# Debian / Ubuntu / Mint
sudo apt update
# Fedora / CentOS / RHEL (modern)
sudo dnf check-update
# CentOS / RHEL (older)
sudo yum check-update
# Arch Linux
sudo pacman -Sy
Install Git with your distribution’s package manager:
| Distribution | Command |
|---|---|
| Debian / Ubuntu / Mint | sudo apt install git |
| Fedora | sudo dnf install git |
| CentOS / RHEL (older) | sudo yum install git |
| Arch Linux | sudo pacman -S git |
| openSUSE | sudo zypper install git |
Verification:
Open a terminal and run:
git --version
You should see output like git version 2.43.0 — the exact number depends on your distribution.
Why package managers are the right path on Linux: They handle dependencies, security updates, and version management. Downloading Git manually on Linux is unnecessary and risks conflicting with the system’s package ecosystem.
3. Installing Git on macOS
macOS has two paths — the easiest is built right in.
Option 1 — Xcode Command Line Tools (recommended):
Open Terminal and type:
git --version
If Git isn’t installed, macOS prompts you to install the Xcode Command Line Tools, which include Git. Click Install, accept the license, and wait. When the installation completes, git --version shows the version.
Option 2 — Homebrew:
If you prefer the latest version over Apple’s slightly older one:
brew install git
Homebrew keeps Git up to date independently of macOS.
Verify:
git --version
4. Verifying Git Works
After installing on any platform, the verification step is the same.
git --version
You should see a version string. If instead you see command not found or 'git' is not recognized, Git isn’t on your PATH — revisit the installation, particularly the PATH setting on Windows.
A second check — see Git’s help:
git --help
This opens the Git manual, confirming the installation is complete and functional.
5. Configuring Git for the First Time
Installation isn’t complete without configuration. Git records an author name and email with every commit — these are required.
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
The --global flag applies these settings to every repository on your machine. Use --local inside a specific project to override them.
Verify the configuration:
git config --global --list
This lists every global setting. You should see your name and email.
Optional but useful settings:
# Default branch name for new repositories
git config --global init.defaultBranch main
# Default editor for commit messages
git config --global core.editor "nano"
# Better diff output with color
git config --global color.ui auto
# Line ending handling (Windows only)
git config --global core.autocrlf true
Each setting stores in ~/.gitconfig — a plain text file you can edit directly if you prefer.
Why this matters now: Git will refuse to commit without an author name and email. Configuring them at install time prevents the first failed commit.
Complete Example Session
# ============================================
# PART 1: CHECK IF GIT IS INSTALLED
# ============================================
git --version
# [ git version 2.43.0 ] (or similar)
# ============================================
# PART 2: INSTALL ON DEBIAN/UBUNTU
# ============================================
sudo apt update
sudo apt install git
# ============================================
# PART 3: INSTALL ON FEDORA
# ============================================
sudo dnf install git
# ============================================
# PART 4: INSTALL ON ARCH
# ============================================
sudo pacman -S git
# ============================================
# PART 5: INSTALL ON MACOS (via Homebrew)
# ============================================
brew install git
# ============================================
# PART 6: VERIFY
# ============================================
git --version
# [ git version 2.43.0 ]
# ============================================
# PART 7: FIRST-TIME CONFIG
# ============================================
git config --global user.name "Kronos"
git config --global user.email "kronos@example.com"
# ============================================
# PART 8: DEFAULT BRANCH NAME
# ============================================
git config --global init.defaultBranch main
# ============================================
# PART 9: VERIFY CONFIG
# ============================================
git config --global --list
# [ user.name=Kronos ]
# [ user.email=kronos@example.com ]
# [ init.defaultbranch=main ]
# ============================================
# PART 10: WHERE CONFIG LIVES
# ============================================
cat ~/.gitconfig
# [ [user] ]
# [ name = Kronos ]
# [ email = kronos@example.com ]
# [ [init] ]
# [ defaultBranch = main ]
# ============================================
# PART 11: OPEN HELP
# ============================================
git --help
# (opens the manual)
Quick Reference
Install Commands
| Platform | Command |
|---|---|
| Windows | Download from git-scm.com/download/win |
| Debian / Ubuntu | sudo apt install git |
| Fedora | sudo dnf install git |
| CentOS / RHEL | sudo yum install git |
| Arch | sudo pacman -S git |
| openSUSE | sudo zypper install git |
| macOS | brew install git or Xcode tools |
First-Time Config
| Setting | Command |
|---|---|
| Name | git config --global user.name "Your Name" |
git config --global user.email "you@example.com" | |
| Default branch | git config --global init.defaultBranch main |
| Editor | git config --global core.editor "nano" |
| Color | git config --global color.ui auto |
| Line endings (Win) | git config --global core.autocrlf true |
Verification
| Command | Purpose |
|---|---|
git --version | Confirm install |
git --help | Open manual |
git config --global --list | Show all global settings |
cat ~/.gitconfig | View raw config file |
Windows Installer — Key Choices
| Screen | Recommended |
|---|---|
| PATH | Git from the command line and 3rd-party software |
| SSH | Use bundled OpenSSH |
| HTTPS | Use the OpenSSL library |
| Line endings | Checkout Windows-style, commit Unix-style |
| Terminal | MinTTY |
| Credential helper | Git Credential Manager Core |
| Extra | Enable file system caching |
Config Scope
| Flag | Applies to |
|---|---|
--system | All users on machine |
--global | Current user |
--local | Current repository only |
Best Practices
✅ Do This:
# Verify after every install
git --version # ✅
# Configure name and email immediately
git config --global user.name "Your Name"
git config --global user.email "you@example.com" # ✅
# Set default branch name
git config --global init.defaultBranch main # ✅
# Use package managers on Linux/macOS
sudo apt install git # ✅
brew install git # ✅
# On Windows, use Git Bash for Unix-style commands
# (right-click folder → Git Bash Here) # ✅
❌ Don’t Do This:
# Don't skip the user.name and user.email config
# Git will refuse to commit # ❌
# Don't use "Use Git and optional Unix tools from the Command Prompt"
# It overrides Windows tools # ❌
# Don't use the wrong line endings setting
# Expecting no CRLF conversion breaks diffs # ❌
# Don't install manually on Linux
# Use the package manager # ❌
# Don't forget --global unless you want repo-specific config
git config user.name "Name" # ⚠️ local only
# Don't hardcode an editor you don't have
git config --global core.editor "code --wait" # ⚠️ only if installed
Common Pitfalls
| Pitfall | Problem | Solution |
|---|---|---|
git: command not found | Not on PATH | Reinstall with PATH option, reopen terminal |
| Commit rejected | No name/email | Set user.name and user.email |
| Wrong line endings | Diffs show every line changed | Configure core.autocrlf |
| Wrong editor opens | Default editor | Set core.editor |
| Old version in package manager | Missing features | Use official installer or Homebrew |
| Two Git installs | Conflicting versions | Uninstall one |
Real-World Examples
1. Verify Git is installed
git --version
Prints the version — confirms Git is available.
2. Install on Ubuntu
sudo apt update
sudo apt install git
Updates package lists, then installs Git.
3. Install on Fedora
sudo dnf install git
The modern Red Hat-based way.
4. Install on Arch
sudo pacman -S git
Arch’s package manager.
5. Install on macOS
brew install git
Latest version via Homebrew.
6. First-time config
git config --global user.name "Kronos"
git config --global user.email "kronos@example.com"
Required before the first commit.
7. Set default branch
git config --global init.defaultBranch main
New repositories start on main, not master.
8. Set editor
git config --global core.editor "nano"
Used for commit messages.
9. View config
git config --global --list
Shows all global settings.
10. Edit config file directly
nano ~/.gitconfig
Every git config --global setting lives here.
Visual: Install Paths by Platform
┌──────────────────────────────────────────────┐
│ Windows │
│ │
│ git-scm.com/download/win │
│ │ │
│ ▼ │
│ Installer wizard │
│ │ │
│ ▼ │
│ Git + Git Bash + Git GUI │
│ │
└──────────────────────────────────────────────┘
┌──────────────────────────────────────────────┐
│ Linux │
│ │
│ Package manager │
│ │ │
│ ▼ │
│ apt / dnf / pacman / zypper │
│ │ │
│ ▼ │
│ Git │
│ │
└──────────────────────────────────────────────┘
┌──────────────────────────────────────────────┐
│ macOS │
│ │
│ Option 1: Xcode Command Line Tools │
│ Option 2: Homebrew │
│ │ │
│ ▼ │
│ Git │
│ │
└──────────────────────────────────────────────┘
Visual: Config Scope
┌──────────────────────────────────────────────┐
│ --system │
│ │
│ /etc/gitconfig │
│ All users on this machine │
│ │
└─────────────────┬────────────────────────────┘
│
▼
┌──────────────────────────────────────────────┐
│ --global │
│ │
│ ~/.gitconfig │
│ This user, all repositories │
│ │
└─────────────────┬────────────────────────────┘
│
▼
┌──────────────────────────────────────────────┐
│ --local │
│ │
│ .git/config │
│ This repository only │
│ │
└──────────────────────────────────────────────┘
Precedence: local → global → system
Visual: Line Endings
┌──────────────────────────────────────────────┐
│ Windows │
│ CRLF (\r\n) │
│ │
│ hello\r\n │
│ │
└──────────────────────────────────────────────┘
┌──────────────────────────────────────────────┐
│ Linux / macOS │
│ LF (\n) │
│ │
│ hello\n │
│ │
└──────────────────────────────────────────────┘
┌──────────────────────────────────────────────┐
│ Recommended setting on Windows: │
│ │
│ core.autocrlf = true │
│ │
│ Checkout: CRLF │
│ Commit: LF │
│ │
│ Result: cross-platform diffs stay clean │
│ │
└──────────────────────────────────────────────┘
Summary
| Task | Command / Action |
|---|---|
| Windows install | Git for Windows installer |
| Linux install | sudo apt install git (or dnf/pacman) |
| macOS install | Xcode tools or brew install git |
| Verify | git --version |
| Config name | git config --global user.name "Name" |
| Config email | git config --global user.email "you@x.com" |
| Default branch | git config --global init.defaultBranch main |
| Default editor | git config --global core.editor "nano" |
| View config | git config --global --list |
| Config file | ~/.gitconfig |
Key takeaways:
- Git for Windows includes Git Bash — a Unix-style terminal that makes tutorials work
- On Windows, choose “Git from the command line and also from 3rd-party software” for PATH
- On Windows, use “Checkout Windows-style, commit Unix-style” for line endings
- On Linux, install through the package manager — never download manually
- On macOS, Git comes with Xcode Command Line Tools, or use Homebrew
- Verify with
git --versionafter every install - Configure name and email before your first commit — Git requires them
- Set
init.defaultBranch mainto avoidmasteron new repositories - Settings live in
~/.gitconfig— editable directly - Config scope: system → global → local, with local winning
Remember: Installing Git is straightforward on every platform, but two things matter most: the PATH option on Windows (so git works everywhere) and the first-time config (name and email). Set those, verify with git --version, and you’re ready to start.
Stop using slow, ad-bloated tool sites! 🤮
🔎 Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)
⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free
🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!