Git Configuration & Setup

Install Git and configure it for version control

10-15 minutes
Beginner
Cross-platform

Prerequisites

Before you begin:

  • • Administrator access to your system
  • • Internet connection for downloading Git
  • • GitHub account (optional but recommended)
  • • Basic command line knowledge

Installation Steps

Windows Installation

Step 1: Download Git

  1. Visit the official Git website: git-scm.com
  2. Click "Download for Windows"
  3. Choose the appropriate version (64-bit recommended)

Step 2: Install Git

  1. Run the downloaded installer as Administrator
  2. Accept the license agreement
  3. Choose installation location (default is fine)
  4. Select components (recommended settings)
  5. Choose default editor (Notepad++ or VS Code recommended)
  6. Choose PATH environment (Git from the command line and also from 3rd-party software)
  7. Choose HTTPS transport backend (OpenSSL library)
  8. Choose line ending conversions (Checkout Windows-style, commit Unix-style line endings)
  9. Choose terminal emulator (Use Windows' default console window)
  10. Choose default behavior of git pull (Default)
  11. Choose credential helper (Git Credential Manager)
  12. Enable file system caching (Yes)
  13. Complete the installation

Step 3: Verify Installation

git --version

You should see output like: git version 2.40.x

macOS Installation

Method 1: Using Homebrew (Recommended)

# Install Homebrew first (if not installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Git
brew install git

Method 2: Official Installer

  1. Visit git-scm.com
  2. Download the macOS installer
  3. Run the installer and follow the wizard
  4. Verify installation with terminal commands

Linux Installation (Ubuntu/Debian)

Install Git

# Update package list
sudo apt update

# Install Git
sudo apt install git

Verify Installation

git --version

Initial Configuration

Set Your Identity

Configure your name and email for Git commits:

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Set Default Branch Name

Configure the default branch name for new repositories:

git config --global init.defaultBranch main

Configure Line Endings

Set up proper line ending handling:

# For Windows
git config --global core.autocrlf true

# For macOS/Linux
git config --global core.autocrlf input

Verify Configuration

git config --list

This will show all your Git configuration settings.

SSH Key Setup (Optional)

Set up SSH for GitHub

SSH keys allow you to connect to GitHub without entering your password each time.

Generate SSH Key

ssh-keygen -t ed25519 -C "[email protected]"

Add SSH Key to SSH Agent

# Start SSH agent
eval "$(ssh-agent -s)"

# Add SSH key
ssh-add ~/.ssh/id_ed25519

Copy Public Key

# Display public key
cat ~/.ssh/id_ed25519.pub

Copy the output and add it to your GitHub account settings.

Verification

Test Your Setup

# Check Git version
git --version

# Check configuration
git config --list

# Test SSH connection (if configured)
ssh -T [email protected]

If you see version information and configuration settings, your setup is successful!

Common Issues & Solutions

'git' is not recognized (Windows)

If you get this error after installation:

  • Restart your command prompt or PowerShell
  • Check if Git was added to PATH during installation
  • Manually add Git to your system PATH if needed

Authentication Issues with GitHub

If you have trouble pushing to GitHub:

  • Set up SSH keys as described above
  • Use GitHub CLI for easier authentication
  • Configure Git credential manager

Next Steps

What to do next:

  • • Create your first Git repository
  • • Learn basic Git commands (add, commit, push, pull)
  • • Set up a GitHub account and create repositories
  • • Learn about branching and merging