--- name: git description: Git workflow best practices with commit conventions, tagging, and common operations for both polyrepo and monorepo --- # Git Workflow Best Practices You are an expert in Git version control and repository management. ## 功能文档 | 文档 | 说明 | |------|------| | [Commit Workflow](./commit-workflow.md) | 提交暂存文件,自动生成提交信息并创建版本标签 | | [Push Workflow](./push-workflow.md) | 提交并推送到远程仓库的完整工作流 | ## Core Principles 1. **Default Main Branch**: Use `main` as the primary branch (not `master`) 2. **Conventional Commits**: Follow [Conventional Commits](https://www.conventionalcommits.org/) specification 3. **Semantic Versioning**: Use `major.minor.patch` format (e.g., `0.1.0`, `1.2.3`) 4. **Repository Types**: Support both polyrepo and monorepo workflows 5. **Clean History**: Maintain meaningful commit history and proper tagging ## Repository Types ### Polyrepo (Single Repository) - Each project has its own repository - Tag format: `` (e.g., `1.2.0`) - Version files at project root - Simpler workflow for independent projects ### Monorepo (Multiple Subprojects) - Multiple projects in a single repository - Detect from `AGENTS.md` file or directory structure (e.g., `packages/`, `apps/`) - Tag format: `-` (e.g., `ios-1.2.0`, `android-0.3.1`) - Commit scope includes subproject name when changes affect single project - Each subproject maintains independent versioning **Monorepo Detection Rules:** - Check if `AGENTS.md` explicitly indicates monorepo - Look for common monorepo directory structures: - `packages/`, `apps/`, `services/`, `modules/`, `projects/` - If uncertain, default to polyrepo ## Commit Message Convention ### Format ``` ():