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
- Download: Visit git-scm.com/download/win and download the latest version
- 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
- Verify: Open Command Prompt or Git Bash and type:Verify Git Installationgit --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 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
xcode-select --install
Option 3: Binary Installer
Download fromgit-scm.com/download/mac
Post-Installation Setup
# Verify installationgit --version # Configure Git to use macOS Keychaingit config --global credential.helper osxkeychain
Linux Installation
Distribution-Specific Commands
Debian/Ubuntu
# Update package indexsudo apt update # Install Gitsudo apt install git
Fedora
sudo dnf install git
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
01# Set your identity02git config --global user.name "Your Name"03git config --global user.email "your.email@example.com"04 05# Set default branch name06git config --global init.defaultBranch main07 08# Set default editor09git config --global core.editor "code --wait"
The --global flag sets these configurations for all repositories on your system.
Advanced Settings
01# Configure line endings02git config --global core.autocrlf true # Windows03git config --global core.autocrlf input # Mac/Linux04 05# Set color UI06git config --global color.ui auto07 08# Configure pull behavior09git config --global pull.rebase false
These settings help ensure consistent behavior across different systems.
Recommended Aliases
01# Add useful shortcuts02git config --global alias.co checkout03git config --global alias.br branch04git config --global alias.ci commit05git config --global alias.st status06git 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
01# Version check02git --version03 04# View all configurations05git config --list06 07# Test Git functionality08git init test-repo09cd test-repo10git status
Verify Configuration
01# Check specific settings02git config user.name03git config user.email04git config core.editor05 06# View all global settings07git 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