Skip to main content
Git Distributed Version Control

Git Crash Course

“I’m an egotistical bastard, and I name all my projects after myself. First Linux, now Git.” - Linus Torvalds
Git is not just a tool. It is the foundation of modern software development. Every professional developer uses it. Every open source project depends on it. Every company you will ever work for expects you to know it. This course takes you from git-curious to git-confident.

Why Git Matters

Every professional developer uses version control. Here’s why Git won:

Distributed

Every developer has the full history. No single point of failure. Work offline.

Fast

Branching and merging are instant. Designed for the Linux kernel (millions of lines).

Industry Standard

GitHub, GitLab, Bitbucket—all built on Git. 97% of developers use it.

Powerful

Branching strategies, rebasing, cherry-picking—handle any workflow.

The Story Behind Git

2005: Linus Torvalds needed a version control system for Linux kernel development. The existing tool (BitKeeper) became proprietary. The Solution: Linus built Git in just 10 days. His goals:
  • Speed (handle Linux kernel scale)
  • Distributed (no central server dependency)
  • Data integrity (cryptographic hashing)
  • Non-linear development (branching)
Today: Git powers:
  • 100+ million repositories on GitHub
  • Every major open source project
  • Companies from startups to Google, Microsoft, Facebook

What You’ll Learn

1

Fundamentals

Repositories, commits, the staging area. The mental model that makes everything else click. Start Here
2

Branching and Merging

Create branches in milliseconds, merge with confidence, resolve conflicts like a pro. Learn Branching
3

Collaboration

Remote repositories, push/pull workflows, pull requests, code review. Working with teams. Collaborate
4

Advanced Topics

Rebase vs merge (the eternal debate), interactive rebase, cherry-pick, stash. Power user territory. Go Advanced
5

Internals Deep Dive

The object model, SHA-1 hashing, packfiles, refs. If you love understanding how things actually work, this one is for you. Explore Internals
6

Git Hooks

Automate workflows, enforce standards, integrate with CI/CD. Git as a platform. Learn Hooks

Git vs Other Version Control Systems

FeatureGitSVNMercurial
ArchitectureDistributedCentralizedDistributed
SpeedVery FastSlowFast
BranchingInstant, cheapSlow, expensiveFast
Offline WorkFull functionalityLimitedFull functionality
Market Share~97%~2%~1%
Learning CurveModerateEasyEasy
Why Git Won: Speed + distributed model + GitHub’s network effect.

Core Concepts Preview

Git Workflow

The Three States

Every file in Git is in one of three states:
  1. Modified: Changed but not staged
  2. Staged: Marked for next commit
  3. Committed: Safely stored in repository

The Three Areas

  1. Working Directory: Your actual files
  2. Staging Area (Index): Prepared changes
  3. Repository (.git): Committed history

Why Developers Love Git

Create a branch in milliseconds. Experiment freely. Delete failed experiments.
git branch feature-x    # Create branch
git checkout feature-x  # Switch to it
# Or in one command:
git checkout -b feature-x
Every commit is a snapshot. Travel back in time. Find when bugs were introduced.
git log --oneline --graph --all
git bisect  # Binary search for bugs
Multiple developers, same codebase, no conflicts (mostly). Pull requests for code review.
git pull origin main
git push origin feature-x
SHA-1 hashing ensures data integrity. Almost impossible to lose committed work.
git reflog  # See everything you've done
git reset --hard HEAD@{1}  # Undo mistakes

Real-World Use Cases

Solo Projects

Track changes, experiment with branches, never lose work

Team Development

Parallel feature development, code review, merge strategies

Open Source

Fork projects, submit pull requests, contribute to Linux, React, etc.

DevOps/CI/CD

Trigger builds on push, deploy from branches, GitOps workflows

Prerequisites

What You Need:
  • Basic command line knowledge (cd, ls, mkdir)
  • A text editor (VS Code, Sublime, Vim)
  • Git installed on your system
Installation:
  • Windows: Download from git-scm.com
  • macOS: brew install git or Xcode Command Line Tools
  • Linux: sudo apt install git (Ubuntu) or sudo yum install git (RHEL)
Verify Installation:
git --version
# Should show: git version 2.x.x

Course Structure

This crash course is designed to take you from zero to productive in 8-10 hours.

Module 1: Fundamentals (2-3 hours)

Git installation, configuration, the mental model. Creating repositories, staging changes, making commits. Understanding the three states and three areas.

Module 2: Branching and Merging (2-3 hours)

Branch creation (it is instant, abuse this), switching contexts, merging strategies, conflict resolution. The workflows that make teams productive.

Module 3: Collaboration (2-3 hours)

Remotes, cloning, fetching, pulling, pushing. Forking repos, creating pull requests, code review etiquette. GitHub/GitLab workflows.

Module 4: Advanced Topics (2-3 hours)

The rebase vs merge debate (both have their place), interactive rebase for clean history, cherry-picking commits, stashing work in progress.

Module 5: Internals Deep Dive (1-2 hours)

The object database, content-addressable storage, SHA-1 hashing, packfiles, refs. If you love internals, continue. If not, you are still a competent Git user.

Module 6: Git Hooks (1 hour)

Pre-commit hooks, pre-push hooks, server-side hooks. Automate quality gates and integrate with CI/CD.

Common Git Workflows

# Create feature branch
git checkout -b feature/user-auth

# Make changes, commit
git add .
git commit -m "Add user authentication"

# Push to remote
git push origin feature/user-auth

# Create pull request on GitHub/GitLab
# After review, merge to main

Git Best Practices

Commit Message Guidelines:
feat: add user authentication
fix: resolve login timeout issue
docs: update README with setup instructions
refactor: simplify database query logic
test: add unit tests for auth service
Follow the Conventional Commits specification.
Commit Often, Push Regularly:
  • Commit logical units of work
  • Write descriptive commit messages
  • Push at least daily to backup your work
  • Use branches for features, fixes, experiments

What Makes Git Powerful

  1. Snapshots, Not Diffs: Git stores complete snapshots, making operations fast
  2. Local Operations: Most operations are local, no network needed
  3. Integrity: Everything is checksummed (SHA-1), corruption is detected
  4. Append-Only: Git generally only adds data, hard to lose committed work
  5. Branching Model: Branches are just pointers, making them lightweight

Learning Path

1

Week 1: Basics

Install Git, learn init/add/commit/log, practice daily commits
2

Week 2: Branching

Create branches, merge changes, resolve conflicts
3

Week 3: Collaboration

Use GitHub/GitLab, fork repos, create pull requests
4

Week 4: Advanced

Master rebase, cherry-pick, understand Git internals

Success Metrics

By the end of this crash course, you will be able to:
  • Initialize repositories and make commits without thinking
  • Create and merge branches with confidence
  • Resolve merge conflicts (they are not as scary as they seem)
  • Collaborate using GitHub/GitLab like you have done it for years
  • Use advanced features like rebase, cherry-pick, and interactive staging
  • Understand Git internals and troubleshoot when things go wrong
  • Follow industry-standard workflows (GitFlow, trunk-based, feature branches)

Ready to master Git? Start with Git Fundamentals or jump to Internals Deep Dive if you want to understand how Git really works.