Git Installation & Setup

Complete guide to installing Git and configuring it for optimal use across all major platforms

Learning Objectives

  • Install Git on your specific operating system with recommended settings
  • Configure Git with best practices for identity, editor, and default settings
  • Understand important Git configuration options and their impact
  • Learn to verify your installation and troubleshoot common setup issues
  • Set up Git for efficient workflow with helpful aliases and tools

Before You Begin

Before installing Git, let's ensure you have everything needed for a smooth setup process. This guide covers all major platforms and will help you make the right choices for your development environment.

System Requirements

Minimum Requirements

  • 256MB RAM (1GB+ recommended)
  • 1GB disk space for Git and repositories
  • Terminal/Command Line access

Supported Platforms

  • Windows 7 SP1 and later
  • macOS 10.13 and later
  • Linux (all major distributions)

Installation Guide

Choose your operating system below for detailed installation instructions. Each guide includes recommended settings and post-installation steps.

Windows Installation

Step-by-Step Instructions

  1. Download: Visit git-scm.com/download/win and download the latest version
  2. Install: Run the installer with these recommended settings:
    • Git Bash and Git GUI
    • Git from the command line
    • Use VS Code as default editor
    • Let Git decide default branch name
    • Git Credential Manager
  3. Verify: Open Command Prompt or Git Bash and type:
    Verify Git Installation
    git --version

Important Notes for Windows Users

  • Enable symbolic links if you plan to use them
  • Choose "Checkout as-is, commit Unix-style" for line endings
  • Install Git Credential Manager for secure authentication

macOS Installation

Installation Options

Option 1: Homebrew (Recommended)
Install Git using Homebrew
# Install Homebrew first if you haven't:
/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
Install Git using Xcode
xcode-select --install
Option 3: Binary Installer

Download fromgit-scm.com/download/mac

Post-Installation Setup

Configure Git on macOS
# Verify installation
git --version
# Configure Git to use macOS Keychain
git config --global credential.helper osxkeychain

Linux Installation

Distribution-Specific Commands

Debian/Ubuntu
Install Git on Debian/Ubuntu
# Update package index
sudo apt update
# Install Git
sudo apt install git
Fedora
Install Git on Fedora
sudo dnf install git
Arch Linux
Install Git on Arch Linux
sudo pacman -S git

Additional Setup for Linux

  • • Consider installing gitk for GUI visualization
  • • Set up credential storage with libsecret
  • • Configure SSH keys for remote repositories

Essential Configuration

After installing Git, you'll need to configure it with your identity and preferences. These settings will be used for all your Git operations.

Basic Configuration

Basic Git Configuration
01# Set your identity
02git config --global user.name "Your Name"
03git config --global user.email "your.email@example.com"
04
05# Set default branch name
06git config --global init.defaultBranch main
07
08# Set default editor
09git config --global core.editor "code --wait"

The --global flag sets these configurations for all repositories on your system.

Advanced Settings

Advanced Git Configuration
01# Configure line endings
02git config --global core.autocrlf true # Windows
03git config --global core.autocrlf input # Mac/Linux
04
05# Set color UI
06git config --global color.ui auto
07
08# Configure pull behavior
09git config --global pull.rebase false

These settings help ensure consistent behavior across different systems.

Recommended Aliases

Git Aliases Configuration
01# Add useful shortcuts
02git config --global alias.co checkout
03git config --global alias.br branch
04git config --global alias.ci commit
05git config --global alias.st status
06git config --global alias.unstage 'reset HEAD --'
07git config --global alias.last 'log -1 HEAD'

Verifying Your Setup

Let's make sure everything is configured correctly by running some verification commands.

Check Installation

Verify Git Installation
01# Version check
02git --version
03
04# View all configurations
05git config --list
06
07# Test Git functionality
08git init test-repo
09cd test-repo
10git status

Verify Configuration

Check Git Configuration
01# Check specific settings
02git config user.name
03git config user.email
04git config core.editor
05
06# View all global settings
07git config --global --list

Troubleshooting Common Issues

Installation Issues

'git' is not recognized

Add Git to your system's PATH variable or reinstall Git selecting the appropriate PATH option.

Permission denied

Run the installation with administrator/sudo privileges.

Configuration Issues

Unable to set config

Check file permissions in your home directory and ensure .gitconfig is writable.

SSL certificate problems

Update your Git installation or configure Git to use your system's certificates.

Ready to Start?

Now that you have Git installed and configured, you're ready to learn about Git's fundamental concepts:

Working Directory

Where you'll modify your files

Staging Area

Where you'll organize your changes

Git Repository

Where your project's history lives