My Git Handbook

June 11, 2026 · View on GitHub

English | 中文

A practical Git/GitHub handbook for modern engineering teams and AI-native development workflows.

Why Maintain This Repository

This repository started as a collection of Git learning materials and has helped many Chinese developers get started with Git.

Today, a link collection is no longer enough. The core challenges of Git have expanded from "how to use commands" to more practical questions:

  1. How individual developers understand Git's mental model.
  2. How to handle conflicts, rollbacks, and accidental commits in daily development.
  3. How teams choose the right branch and PR workflows.
  4. How engineering leads establish collaboration standards using GitHub.
  5. How to review, split, verify, and revert AI-generated code changes in AI-native development workflows.

Therefore, v2.0 upgrades this repository into:

A practical Git/GitHub handbook for modern engineering teams and AI-native development workflows.

Who Is This For?

  • Git beginners looking to build the right mental model.
  • Practicing developers who frequently need to handle conflicts, rollbacks, and accidental commits.
  • Senior developers focused on PRs, Review, CI, and release collaboration.
  • Technical leads who need to design team Git workflows and GitHub governance standards.
  • AI coding users who need to control the risks of code changes brought by tools like Codex, Claude Code, Cursor, and Cline.

Directory Navigation

DirectoryProblems Solved
01-getting-startedGit basics, mental models, and the difference between Git and SVN
02-daily-workflowDaily commands, branching and merging, rebase, stash, and worktree
03-team-collaborationTeam workflows, PRs, Code Review, and selecting collaboration models
04-github-engineeringBranch protection, Rulesets, CODEOWNERS, CI, releases, and security
05-ai-native-developmentDiff review, commit splitting, worktree, and multi-agent strategies for AI coding
06-troubleshootingRecovering from Git mishaps, conflict resolution, secret cleaning, and force push recovery
07-large-repoLarge repositories, monorepos, partial clone, sparse checkout, and Git LFS
08-templatesTemplates for PRs, Issues, Reviews, Hotfixes, Releases, and AI Reviews
10-company-practicesEnterprise engineering practice cases and decision maps

Learning Paths

Beginner Path

  1. Why Use Git
  2. Git Mental Model
  3. Git Basic Commands
  4. Everyday Git Commands

Daily Development Path

  1. Branch and Merge
  2. Rebase vs. Merge
  3. Stash
  4. Worktree

Team Collaboration Path

  1. Team Git Workflow Guide
  2. GitLab Flow
  3. Pull Request Best Practices
  4. Code Review Best Practices
  5. GitHub Flow
  6. Trunk-Based Development
  7. Gitflow

GitHub Engineering Governance Path

  1. GitHub Engineering Governance Manual
  2. Enterprise GitHub Workflow Stack
  3. Branch Protection
  4. Rulesets
  5. Merge Queue
  6. GitOps and Config as Code
  7. Release Management
  8. AI Agent Governance

AI Native Development Path

  1. AI Native Git Workflow
  2. AI-Generated Code Review
  3. Codex / Claude Code Git Practices
  4. Git Integration Practices for AI Coding Tools
  5. Worktree for AI Agents
  6. Stacked PR for AI-Generated Changes
  7. AI Reviewer and Human Reviewer

Troubleshooting Path

  1. Git Troubleshooting Playbook
  2. Undo Anything
  3. Recover Lost Commit
  4. Remove Secret from History

Find Answers by Problem

The problem I'm facingSuggested reading
Just committed to the wrong branchCommitted to Wrong Branch
Don't know how to recover after reset, rebase, or force pushGit Troubleshooting Playbook
Team doesn't know whether to choose GitHub Flow, Gitflow, or Trunk-Based DevelopmentTeam Git Workflow Guide
PR is too large, review is slowPull Request Best Practices
AI changed too many files at once, don't know how to reviewAI Change Review Examples
Large AI-generated diff needs to be split into commits or PRsAI Commit Splitting, Stacked PR for AI-Generated Changes
Want to protect the main branchBranch Protection
AI agents are pushing code and opening PRs, and I don't know how to govern themAI Agent Governance
Want an agent collaboration convention for the team repositoryAGENTS.md Template
Too many PRs, main branch often broken after mergeMerge Queue
Clone, status, or checkout is slow in a large repositoryLarge Repository Git Practices
Want to directly copy team templatesTemplates

Phase 1: Must-Read Articles

New content will prioritize official documentation and industry-standard materials:

For a more complete index of materials, see Recommended Reading.

v2.0 Maintenance Plan

See the roadmap for detailed plans.

Existing content will be gradually incorporated into new learning paths. See the legacy content migration for the migration list and the resources index for the materials index.

Project Governance

Original project content is licensed under the MIT License. Third-party materials, archived ebooks, external articles, linked resources, and quoted references remain under their original licenses and copyrights.

Contributing

We welcome contributions of real-world problems, team practices, incident recovery experiences, AI programming workflows, and reusable templates.

Please follow the Content Style Guide for new content.