Overview
This series teaches Git through heavily annotated, self-contained examples. Each example demonstrates a concrete Git operation with inline annotations that explain the command, its options, and the resulting state of the repository.
How This Series Is Organized
Examples are grouped by complexity:
- Beginner: Initializing a repository, staging files, committing, viewing history, and working with remotes.
- Intermediate: Branching, merging, rebasing, resolving conflicts, stashing, and tagging.
- Advanced: Interactive rebase, cherry-picking, bisect, hooks, worktrees, and submodules.
Structure of Each Example
Every example follows a consistent five-part format:
- Brief Explanation — what the operation does and why it matters (2-3 sentences)
- Mermaid Diagram — visual representation of repository state, branch topology, or workflow (when appropriate)
- Heavily Annotated Commands — shell commands with
# =>comments describing the effect and resulting state - Key Takeaway — the core insight to retain from the example (1-2 sentences)
- Why It Matters — production relevance and real-world impact (50-100 words)
Examples by Level
Beginner (Examples 1–28)
- Example 1: Initialize a Local Repository
- Example 2: Configure User Identity
- Example 3: Check Repository Status
- Example 4: Stage Files with git add
- Example 5: Create Your First Commit
- Example 6: View Commit History with git log
- Example 7: Formatted git log with Graph
- Example 8: Inspect a Specific Commit with git show
- Example 9: See Unstaged and Staged Differences
- Example 10: Create a .gitignore File
- Example 11: Restore a File to Last Committed State
- Example 12: Unstage a Staged File
- Example 13: Create and List Branches
- Example 14: Switch Between Branches with git switch
- Example 15: Create and Switch in One Command
- Example 16: Clone a Remote Repository
- Example 17: Inspect Remote Configuration
- Example 18: Push Commits to a Remote
- Example 19: Fetch Remote Changes
- Example 20: Pull Remote Changes
- Example 21: Understanding HEAD
- Example 22: Remove Tracked Files with git rm
- Example 23: Rename or Move Files with git mv
- Example 24: View History of a Specific File
- Example 25: Delete a Branch
- Example 26: Fast-Forward Merge
- Example 27: Detailed git status and Short Format
- Example 28: Search Through Commit History with git log Filters
Intermediate (Examples 29–57)
- Example 29: Three-Way Merge
- Example 30: Merge Conflict Resolution
- Example 31: git rebase (Basic Linear Rebase)
- Example 32: git rebase --onto (Selective Rebase)
- Example 33: git stash save and pop
- Example 34: git stash list, apply, and drop
- Example 35: git tag (Lightweight and Annotated)
- Example 36: git remote (add, remove, rename)
- Example 37: git remote prune and Tracking Branches
- Example 38: git cherry-pick
- Example 39: git blame
- Example 40: git reflog
- Example 41: git reset --soft, --mixed, --hard
- Example 42: git revert
- Example 43: git clean
- Example 44: .gitattributes
- Example 45: Git Hooks (pre-commit)
- Example 46: Git Hooks (commit-msg and pre-push)
- Example 47: git config (Local, Global, System)
- Example 48: Git Aliases
- Example 49: git log Advanced (--graph, --oneline, --author, date ranges)
- Example 50: git diff Advanced (--cached, branch comparison, stat)
- Example 51: Merge Strategies (ours and theirs)
- Example 52: Tracking Branches and Upstream Configuration
- Example 53: git log with Merge History Filtering
- Example 54: git diff with Word-Level and Whitespace Options
- Example 55: git bisect
- Example 56: git shortlog and Contribution Statistics
- Example 57: git archive and Bundle
Advanced (Examples 58–88)
- Example 58: Interactive Rebase — Squash, Fixup, Reword, Edit, Drop
- Example 59: Interactive Rebase —
editto Amend a Mid-History Commit - Example 60: Git Worktree — Parallel Working Directories
- Example 61: Git Worktree — Lock, Unlock, and Move
- Example 62: Git Worktree — Bare Repository Workflow
- Example 63: Git Worktree — Practical Multi-Task Development
- Example 64: Git Bisect — Manual Binary Search for a Regression
- Example 65: Git Bisect — Automated Binary Search with a Test Script
- Example 66: Git Submodule — Add, Clone, Update, foreach, deinit
- Example 67: Git Subtree — Embed and Split a Project
- Example 68:
git filter-repo— Rewrite Repository History - Example 69: Git Rerere — Record and Reuse Conflict Resolutions
- Example 70: Git Notes — Attach Metadata Without Altering Commits
- Example 71: Git Bundle — Offline Transfer of Repository Data
- Example 72: Git Archive — Export Clean Source Snapshots
- Example 73: Git Sparse-Checkout — Check Out Only a Subdirectory
- Example 74: Git Maintenance — Automated Background Repository Optimization
- Example 75: The Git Object Model — Blobs, Trees, Commits, Tags
- Example 76: Packfiles and
git gc— How Git Compresses Object Storage - Example 77: Shallow Clone and Partial Clone — Fast CI Checkouts
- Example 78: Git LFS — Storing Large Binary Files Outside the Object Store
- Example 79: Advanced Merge Strategies — Octopus, Recursive with Options, and Ours
- Example 80:
git range-diff— Compare Two Versions of a Patch Series - Example 81: Signing Commits with GPG — Verified Authorship
- Example 82:
git replace— Non-Destructive History Grafting - Example 83:
git fsck— Filesystem Consistency Check - Example 84: Monorepo Strategies with Git — Nx, Sparse Checkout, and CODEOWNERS
- Example 85: Git Attributes and Custom Diff Drivers in a Monorepo
- Example 86: Git Hooks in a Team — Husky, lint-staged, and Commit-msg Validation
- Example 87:
git bisectCombined with Git Notes — Document Regression Findings - Example 88: Git Reflog — Recovering Lost Commits and Branches
Last updated March 19, 2026