📦 xirong/my-git:面向现代工程团队与 AI 原生开发流程的 Git/GitHub 实战手册
英文标题:📦 xirong/my-git
该仓库升级为 v2.0 版本,从原本的 Git 学习资源合集转变为覆盖个人、团队、AI 编程全场景的实战手册。其核心挑战已从“如何使用命令”扩展至心智模型建立、日常回滚、团队协作、GitHub 工程治理以及 AI 代码变更风险控制。手册系统梳理了入门、日常操作、团队协作、AI 原生开发、故障排查等八大目录,并提供典型问题速查表,帮助开发者快速找到解决方案。对现代工程团队而言,这相当于一份可直接落地、应对 AI 编码时代新问题的权威工作指南。
124.8 KB
中文
English | 中文
一份面向现代工程团队与 AI 原生开发流程的实用 Git/GitHub 手册。
为何维护此仓库
该仓库最初是一组 Git 学习资料的合集,曾帮助众多中文开发者入门 Git。
如今,简单的链接合集已远远不够。Git 的核心挑战已从“如何使用命令”扩展为更实际的问题:
- 个人开发者如何理解 Git 的心智模型。
- 日常开发中如何处理冲突、回滚与误操作提交。
- 团队如何选择合适的分支与 PR 工作流。
- 工程负责人如何利用 GitHub 建立协作规范。
- 在 AI 原生开发流程中,如何审查、拆分、验证和回撤 AI 生成的代码变更。
因此,v2.0 版本将本仓库升级为:
一份面向现代工程团队与 AI 原生开发流程的实用 Git/GitHub 手册。
- Git 初学者,希望建立正确的心智模型。
- 一线开发者,经常需要处理冲突、回滚和误操作提交。
- 资深开发者,关注 PR、Review、CI 与发布协作。
- 技术负责人,需要设计团队 Git 工作流与 GitHub 治理标准。
- AI 编码用户,需要管控 Codex、Claude Code、Cursor、Cline 等工具带来的代码变更风险。
| 目录 | 解决的问题 |
|---|---|
| 01-getting-started | Git 基础、心智模型以及 Git 与 SVN 的区别 |
| 02-daily-workflow | 日常命令、分支与合并、rebase、stash 和 worktree |
| 03-team-collaboration | 团队工作流、PR、代码评审以及协作模型选择 |
| 04-github-engineering | 分支保护、Rulesets、CODEOWNERS、CI、发布与安全 |
| 05-ai-native-development | AI 编码场景下的 diff 审查、提交拆分、worktree 和多智能体策略 |
| 06-troubleshooting | 从 Git 事故中恢复、冲突解决、密钥清理和强制推送恢复 |
| 07-large-repo | 大仓库、monorepo、部分克隆、稀疏检出和 Git LFS |
| 08-templates | PR、Issue、Review、Hotfix、Release 和 AI Review 的模板 |
| 10-company-practices | 企业工程实践案例与决策图谱 |
GitHub 工程治理路径
AI 原生开发路径
| 我面临的问题 | 建议阅读 |
|---|---|
| 刚刚提交到了错误的分支 | 提交到错误分支 |
| 在 reset、rebase 或 force push 后不知道如何恢复 | Git 故障排查手册 |
| 团队不确定该选择 GitHub Flow、Gitflow 还是主干开发 | 团队 Git 工作流指南 |
| PR 体积过大,评审缓慢 | Pull Request 最佳实践 |
| AI 一次性修改了太多文件,不知如何审查 | AI 变更审查示例 |
| AI 生成的巨大 diff 需要拆分成多个提交或 PR | AI 提交拆分、面向 AI 生成变更的 Stacked PR |
| 希望保护主分支 | 分支保护 |
| AI 智能体正在推送代码并开启 PR,我不知道如何治理它们 | AI Agent 治理 |
| 希望为团队仓库制定 Agent 协作约定 | AGENTS.md 模板 |
| PR 过多,主分支在合并后经常被破坏 | 合并队列 Merge Queue |
| 在大仓库中 clone、status 或 checkout 很慢 | 大仓库 Git 实践 |
| 希望直接复制团队模板 | 模板 |
第一阶段:必读文章
新增内容将优先选用官方文档和行业标准资料:
如需更完整的资料索引,请参见推荐阅读。
详细计划请查看路线图。
现有内容将逐步纳入新的学习路径。参见遗留内容迁移了解迁移列表,参见资源索引查看资料索引。
原始项目内容采用 MIT 许可证。第三方资料、存档电子书、外部文章、链接资源以及引用的参考文献仍受其原始许可证和版权保护。
我们欢迎贡献真实世界的问题、团队实践、事故恢复经验、AI 编程工作流以及可复用的模板。
新增内容请遵循内容风格指南。
English / 原文
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:
- How individual developers understand Git's mental model.
- How to handle conflicts, rollbacks, and accidental commits in daily development.
- How teams choose the right branch and PR workflows.
- How engineering leads establish collaboration standards using GitHub.
- 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.
- 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 | Problems Solved |
|---|---|
| 01-getting-started | Git basics, mental models, and the difference between Git and SVN |
| 02-daily-workflow | Daily commands, branching and merging, rebase, stash, and worktree |
| 03-team-collaboration | Team workflows, PRs, Code Review, and selecting collaboration models |
| 04-github-engineering | Branch protection, Rulesets, CODEOWNERS, CI, releases, and security |
| 05-ai-native-development | Diff review, commit splitting, worktree, and multi-agent strategies for AI coding |
| 06-troubleshooting | Recovering from Git mishaps, conflict resolution, secret cleaning, and force push recovery |
| 07-large-repo | Large repositories, monorepos, partial clone, sparse checkout, and Git LFS |
| 08-templates | Templates for PRs, Issues, Reviews, Hotfixes, Releases, and AI Reviews |
| 10-company-practices | Enterprise engineering practice cases and decision maps |
GitHub Engineering Governance Path
- GitHub Engineering Governance Manual
- Enterprise GitHub Workflow Stack
- Branch Protection
- Rulesets
- Merge Queue
- GitOps and Config as Code
- Release Management
- AI Agent Governance
AI Native Development Path
| The problem I'm facing | Suggested reading |
|---|---|
| Just committed to the wrong branch | Committed to Wrong Branch |
| Don't know how to recover after reset, rebase, or force push | Git Troubleshooting Playbook |
| Team doesn't know whether to choose GitHub Flow, Gitflow, or Trunk-Based Development | Team Git Workflow Guide |
| PR is too large, review is slow | Pull Request Best Practices |
| AI changed too many files at once, don't know how to review | AI Change Review Examples |
| Large AI-generated diff needs to be split into commits or PRs | AI Commit Splitting, Stacked PR for AI-Generated Changes |
| Want to protect the main branch | Branch Protection |
| AI agents are pushing code and opening PRs, and I don't know how to govern them | AI Agent Governance |
| Want an agent collaboration convention for the team repository | AGENTS.md Template |
| Too many PRs, main branch often broken after merge | Merge Queue |
| Clone, status, or checkout is slow in a large repository | Large Repository Git Practices |
| Want to directly copy team templates | Templates |
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.
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.
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.
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.