The Complete Practical Guide: Fundamentals, Workflows, Internals, and Real-World Problem Solving
Introduction
Chapter 1: The Git Mental Model
- The Version Control Landscape
- The Directed Acyclic Graph
- The Three-Tree Model
- Object Types: Blob, Tree, Commit, Tag
- References: Branches, Tags, and HEAD
Chapter 2: Installation and Configuration
- Installing Git
- The Config Layers: System, Global, Local
- Identity and Email
- Authentication: SSH vs HTTPS
- Essential Settings
Chapter 3: Your First Repository
- Initializing a Repository
- The Add/Commit Cycle
- Viewing History
- Undoing Mistakes
- Hands-On Exercise: Build a Tiny Project
Chapter 4: Commits and History Management
- Commit Anatomy
- Amending and Rewriting
- Interactive Rebase Deep Dive
- Cherry-Pick: Applying Individual Commits
- Commit Messages That Matter
- Hands-On Exercise: Amend and Rewrite a Commit
Chapter 5: Branching and Merging
- Creating and Switching Branches
- Merge Strategies: Fast-Forward vs Recursive vs Octopus
- Merge Conflicts: What Causes Them and How to Resolve
- Three-Way Merge Explained
- Hands-On Exercise: Simulate a Real Merge Conflict
Chapter 6: Rebasing and Linear History
- Why Rebase? Clean History vs Merge Commits
- Interactive Rebase in Practice
- Rebase Conflicts: How They Differ from Merge Conflicts
- Walkthrough: Resolving a Rebase Conflict Step by Step
- Hands-On Exercise: Clean Up a Messy History
- The Great Debate: Rebase vs Merge
- Hands-On Exercise: Rebase a Feature Branch
Chapter 7: Remotes and Collaboration
- Remote Mechanics: Fetch, Pull, Push
- Tracking Branches and Upstream/Downstream
- The Push/Pull Cycle
- Force Push Dangers
- Pull Requests and Code Review
- Hands-On Exercise: Fork, Clone, Branch, Commit, Push, and PR
Chapter 8: Advanced Branching Workflows
- Git Flow: The Classic Model
- Trunk-Based Development: The Modern Approach
- Feature Flags and Deployment
- Monorepos: Managing Multiple Projects in One Repo
- Choosing a Strategy
Chapter 9: Stashing, Tagging, and Cleanup
- Stash Mechanics: Saving Changes Without Committing
- Patch Stashes: Stashing Selective Changes
- Tags: Lightweight vs Annotated
- Cleanup Commands
- Hands-On Exercise: Stash, Work on Another Branch, Apply
Chapter 10: Git Hooks and Automation
- Hook Types: Pre-Commit, Pre-Push, Commit-Message
- Writing Your First Hook
- Hook Templates: Sharing Hooks Across Repos
- CI/CD Integration
- Hands-On Exercise: Create a Pre-Commit Hook
Chapter 11: Submodules and Worktrees
- Submodule Mechanics: Add, Update, Clone
- Common Submodule Pitfalls
- Git Worktrees: The Modern Alternative
- When to Use Which
- Hands-On Exercise: Set Up a Repo with a Submodule and a Worktree
Chapter 12: Git Internals
- The Object Store: Blob, Tree, Commit, Tag in
.git/objects - SHA-1 and Content Addressing
- Packfiles and Compression
- The Reflog: Where Deleted Branches Go
- How
git logWorks Under the Hood - Hands-On Exercise: Explore the Object Store with
git cat-file
Chapter 13: Performance and Scale
- Large Repositories: What “Large” Means and Common Bottlenecks
- Shallow Clones:
--depthand Trade-Offs - Sparse Checkout: Checking Out Only What You Need
- Partial Clones: Skipping Large Blobs
- Bisection for Debugging: Finding Regressions Fast
- Performance Tuning:
git configOptions - Hands-On Exercise: Use
git bisectto Find a Regression
Chapter 14: Security and Best Practices
- Signed Commits: GPG and SSH Signing
- Secrets in History: Removal and Prevention
- Audit Trails and Compliance
- Security Scanning: Pre-Commit and CI Integration
- Hands-On Exercise: Remove a Committed Secret
Chapter 15: Troubleshooting and Recovery
- Lost Commits: The Reflog as Your Safety Net
- Corrupted Repositories:
git fsckand Repair - Common Error Patterns: Causes and Fixes
- Recovery Scenarios: Step-by-Step Procedures
- Hands-On Exercise: Simulate a Corrupted Repo and Recover
