🚀 Git Setup - Hands-On Reference

Azure DevOps Fundamentals - Day 1

📋 Session Overview

What You'll Accomplish Today

  • ✅ Understand version control concepts
  • ✅ Install Git on your machine
  • ✅ Configure Git with your identity
  • ✅ Set up essential Git preferences
  • ✅ Verify your Git installation

Prerequisites

Time Allocation

Activity Duration Description
Installation 8 minutes Download and install Git
Configuration 10 minutes Set up user identity and preferences
Practice 5 minutes Run commands and verify setup
Keep this page open in a separate tab/window while following along with the instructor!

⬇️ Git Installation

🪟 Windows
🍎 macOS
🐧 Linux

Windows Installation

1 Download Git

Visit: https://git-scm.com/download/win

Download the latest 64-bit version for Windows

2 Run the Installer

Double-click the downloaded .exe file

Accept the license agreement

3 Important Installation Options
  • ✅ Select additional tasks: Check "Git Bash Here" and "Git GUI Here"
  • ✅ Default editor: Choose "Visual Studio Code" (or your preference)
  • ✅ Path environment: Select "Git from the command line and also from 3rd-party software"
  • ✅ HTTPS transport: Use "Use the OpenSSL library"
  • ✅ Line endings: "Checkout Windows-style, commit Unix-style line endings"
  • ✅ Terminal emulator: "Use MinTTY"
  • ✅ Enable file system caching
  • ✅ Enable Git Credential Manager
4 Complete Installation

Click "Install" and wait for completion

Click "Finish" to exit the installer

5 Verify Installation

Open Command Prompt or Git Bash and run:

git --version

Expected output: git version 2.43.0 (or similar)

⚠️ Common Issue: If "git: command not found" appears, you may need to restart your terminal or add Git to your PATH manually.

macOS Installation

1 Option A: Using Homebrew (Recommended)

If you have Homebrew installed:

brew install git
2 Option B: Download Installer

Visit: https://git-scm.com/download/mac

Download and run the .dmg installer

Follow the installation wizard

3 Option C: Xcode Command Line Tools

Git comes bundled with Xcode Command Line Tools:

xcode-select --install
4 Verify Installation

Open Terminal and run:

git --version

Expected output: git version 2.39.0 (or similar)

We recommend using Homebrew for easier updates in the future!

Linux Installation

1 Ubuntu/Debian
# Update package index
sudo apt update

# Install Git
sudo apt install git -y
2 Fedora/RHEL/CentOS
# Fedora 22+ / RHEL 8+
sudo dnf install git -y

# Older versions
sudo yum install git -y
3 Arch Linux
sudo pacman -S git
4 Verify Installation
git --version

Expected output: git version 2.39.0 (or similar)

⚙️ Git Configuration

Why Configure Git?

Every Git commit uses your configured name and email. This information is permanently baked into the commits you create and is essential for tracking contributions and collaboration.

1. Set Your Identity

This is the most important configuration. Your identity will appear in every commit you make.

# Set your name
git config --global user.name "Your Full Name"

# Set your email (use your company/organizational email)
git config --global user.email "your.email@company.com"
⚠️ Important: Use the email associated with your Azure DevOps account for proper commit attribution!

2. Configure Default Editor

Set your preferred text editor for Git operations:

# For Visual Studio Code
git config --global core.editor "code --wait"

# For Vim
git config --global core.editor "vim"

# For Nano
git config --global core.editor "nano"

# For Notepad++ (Windows)
git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

3. Configure Line Endings

Prevent issues when working across different operating systems:

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

# For macOS/Linux
git config --global core.autocrlf input
Windows uses CRLF (\\r\\n) line endings, while Unix/Mac uses LF (\\n). This setting handles the conversion automatically!

4. Set Default Branch Name

Set the default branch name to 'main' (modern standard):

git config --global init.defaultBranch main

5. Enable Helpful Features

# Enable colored output
git config --global color.ui auto

# Enable credential caching (saves passwords temporarily)
git config --global credential.helper cache

# Windows: Use Git Credential Manager
git config --global credential.helper manager-core

# Set cache timeout to 1 hour (3600 seconds)
git config --global credential.helper 'cache --timeout=3600'

6. Additional Useful Configurations

# Show short status format
git config --global status.short true

# Enable auto-correct for mistyped commands
git config --global help.autocorrect 20

# Set default pull behavior
git config --global pull.rebase false

Complete Configuration Script

Copy and run this complete configuration:

# Essential Git Configuration
# Replace "Your Name" and email with your actual details

git config --global user.name "Your Full Name"
git config --global user.email "your.email@company.com"
git config --global core.editor "code --wait"
git config --global init.defaultBranch main
git config --global color.ui auto

# Windows-specific (skip on Mac/Linux)
git config --global core.autocrlf true
git config --global credential.helper manager-core

# Mac/Linux-specific (skip on Windows)
# git config --global core.autocrlf input
# git config --global credential.helper cache

✅ Verification & Testing

1. Check Git Version

git --version

Expected output: git version 2.43.0 or higher

2. View All Configurations

# View all settings
git config --list

# View with origin paths
git config --list --show-origin

This will show all your Git configurations and where they're stored.

3. Check Specific Settings

# Check your name
git config user.name

# Check your email
git config user.email

# Check default editor
git config core.editor

# Check default branch
git config init.defaultBranch

4. Expected Output

Your configuration should look similar to this:

user.name=John Doe
user.email=john.doe@company.com
core.editor=code --wait
core.autocrlf=true
init.defaultbranch=main
color.ui=auto
credential.helper=manager-core

Configuration Levels

Level Scope Command
--system All users on the system git config --system
--global All repositories for current user git config --global
--local Specific repository only git config --local
Most of the time, you'll use --global which applies to all your repositories!

🔧 Troubleshooting

Problem: "git: command not found"

Windows:

  • Restart your terminal/command prompt
  • Verify Git is in PATH: echo %PATH%
  • Reinstall Git and ensure "Add to PATH" is selected
  • Manually add Git to PATH: C:\Program Files\Git\cmd

macOS/Linux:

  • Verify installation: which git
  • Check PATH: echo $PATH
  • Restart terminal
  • Reinstall using your package manager

Problem: Permission Denied Errors

Linux/macOS:

# Use sudo for installation
sudo apt install git

# Check file permissions
ls -la ~/.gitconfig

Problem: Can't Change Configuration

Solutions:

  • Check if config file is read-only
  • Remove and recreate: rm ~/.gitconfig
  • Edit manually: nano ~/.gitconfig
  • Use --replace-all flag: git config --global --replace-all user.name "New Name"

Problem: Xcode Command Line Tools Prompt (macOS)

If you see a popup asking to install command line tools:

  • Click "Install" and wait for completion
  • Or manually install: xcode-select --install

Problem: Git Credential Manager Not Working

Windows:

# Reinstall Git Credential Manager
git credential-manager-core configure

# Or use Windows Credential Manager
git config --global credential.helper manager

Need More Help?

Resources:

📝 Completion Checklist

Mark each item as you complete it. All items should be checked before moving to Day 2!

Installation

Configuration

Verification

Understanding

🎉 Congratulations!

Once all items are checked, you've successfully completed Day 1!

Next Up: Day 2 - Git Init, Commits, Staging & History