Installing and Configuring Git
Before you can use Git, you need to install it and set up your identity. This lesson covers installation on all major platforms and essential configuration.
Installing Git
Windows
There are several ways to install Git on Windows:
Option 1: Git for Windows (Recommended)
- Download from git-scm.com
- Run the installer
- Accept the default options (or customize as needed)
- Git Bash will be installed for command-line access
Option 2: Using winget
winget install Git.Git
Option 3: Using Chocolatey
choco install git
macOS
Option 1: Xcode Command Line Tools
xcode-select --install
Option 2: Homebrew (Recommended)
brew install git
Option 3: Download Installer Download from git-scm.com
Linux
Debian/Ubuntu:
sudo apt update
sudo apt install git
Fedora:
sudo dnf install git
Arch Linux:
sudo pacman -S git
Verifying Installation
After installation, open a terminal and verify Git is installed:
git --version
You should see output like:
git version 2.43.0
Configuring Git
Git needs to know who you are for commit attribution. This information is attached to every commit you make.
Setting Your Identity
Configure your name and email (use your real information):
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Configuration Levels
Git has three configuration levels:
| Level | Flag | Location | Scope |
|---|---|---|---|
| System | --system | /etc/gitconfig | All users on the system |
| Global | --global | ~/.gitconfig | All repos for current user |
| Local | --local | .git/config | Current repository only |
Local settings override global, which override system.
Viewing Configuration
To see your current configuration:
# Show all settings
git config --list
# Show specific setting
git config user.name
git config user.email
Essential Configuration Options
Default Branch Name
Set the default branch name for new repositories:
git config --global init.defaultBranch main
Default Editor
Set your preferred text editor for commit messages:
# VS Code
git config --global core.editor "code --wait"
# Vim
git config --global core.editor "vim"
# Nano
git config --global core.editor "nano"
# Notepad++ (Windows)
git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
Line Endings
Configure how Git handles line endings across platforms:
# Windows: Convert LF to CRLF when checking out
git config --global core.autocrlf true
# Mac/Linux: Convert CRLF to LF when committing
git config --global core.autocrlf input
Colorful Output
Enable colored output (usually enabled by default):
git config --global color.ui auto
Useful Aliases
Aliases create shortcuts for common commands:
# Short status
git config --global alias.st status
# Short commit
git config --global alias.co checkout
# Pretty log
git config --global alias.lg "log --oneline --graph --decorate"
# Amend last commit
git config --global alias.amend "commit --amend --no-edit"
Now you can use:
git st # instead of git status
git co main # instead of git checkout main
git lg # pretty one-line log with graph
Exercise: Configure Git
Configure your Git identity and verify the settings:
SSH vs HTTPS Authentication
When connecting to remote repositories like GitHub, you can use SSH or HTTPS:
HTTPS
- Easier to set up
- Works through firewalls
- Requires entering credentials (or using a credential manager)
SSH (Recommended)
- More secure
- No password prompts after setup
- Requires generating SSH keys
To set up SSH keys:
# Generate a new SSH key
ssh-keygen -t ed25519 -C "your.email@example.com"
# Start the SSH agent
eval "$(ssh-agent -s)"
# Add your key to the agent
ssh-add ~/.ssh/id_ed25519
# Copy your public key
cat ~/.ssh/id_ed25519.pub
# Add this to your GitHub account settings
Troubleshooting
"git is not recognized"
- Windows: Restart your terminal or computer
- Add Git to your PATH manually
Permission Issues
- Linux/Mac: Use
sudofor system-wide installation - Check file permissions in your home directory
SSL Certificate Issues
# Only if you understand the security implications
git config --global http.sslVerify false
Summary
- Install Git using your platform's package manager or installer
- Verify installation with
git --version - Configure your identity with
user.nameanduser.email - Set useful options like
init.defaultBranchandcore.editor - Create aliases for frequently used commands
- Consider setting up SSH keys for authentication
In the next lesson, we'll create your first Git repository!

