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
- Visit the official Git website: git-scm.com
- Click "Download for Windows"
- Choose the appropriate version (64-bit recommended)
Step 2: Install Git
- Run the downloaded installer as Administrator
- Accept the license agreement
- Choose installation location (default is fine)
- Select components (recommended settings)
- Choose default editor (Notepad++ or VS Code recommended)
- Choose PATH environment (Git from the command line and also from 3rd-party software)
- Choose HTTPS transport backend (OpenSSL library)
- Choose line ending conversions (Checkout Windows-style, commit Unix-style line endings)
- Choose terminal emulator (Use Windows' default console window)
- Choose default behavior of git pull (Default)
- Choose credential helper (Git Credential Manager)
- Enable file system caching (Yes)
- 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
- Visit git-scm.com
- Download the macOS installer
- Run the installer and follow the wizard
- 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