# Commit Message 规范 本项目采用 [Conventional Commits](https://www.conventionalcommits.org/) 规范。 ## 格式 ``` (): [optional body] [optional footer(s)] ``` ## 示例 ``` feat(api): add workspace member invitation endpoint fix(frontend): correct sidebar collapse state on resize docs: update API documentation for /repos endpoints refactor(service): extract auth logic into separate module hotfix(k8s): add missing health probe for gitserver ``` ## Type | Type | Description | |------|-------------| | `feat` | 新功能 | | `fix` | Bug 修复 | | `docs` | 仅文档变更 | | `style` | 代码格式(不影响功能) | | `refactor` | 重构(不是修复也不是新功能) | | `perf` | 性能优化 | | `test` | 添加或修正测试 | | `chore` | 构建或辅助工具变更 | | `build` | 影响构建系统或依赖 | | `ci` | CI/CD 配置 | | `revert` | 回滚之前的提交 | ## Scope | Scope | 说明 | |-------|------| | `frontend` | React 前端 | | `api` | REST API 路由 | | `service` | 业务逻辑层 | | `models` | 数据库模型 | | `k8s` | Kubernetes 部署 | | `deploy` | Docker/Helm 部署 | | `git` | Git 仓库功能 | | `room` | 实时聊天 | | `agent` | AI Agent | | `db` | 数据库迁移 | ## 规则 1. **每条提交应仅包含一个逻辑变更** 2. **description 首字母小写,使用祈使句** 3. **禁止句号结尾** 4. **Body 解释 what 和 why,不解释 how** 5. **Footer 引用相关 Issue** ## Git Alias 在 `~/.gitconfig` 中添加快捷别名: ```ini [alias] co = checkout cm = commit -m lg = log --oneline --graph --decorate amend = commit --amend --no-edit uncommit = reset --soft HEAD~1 ``` 或使用 commitlint 钩子自动验证(见 `.husky/commit-msg`)。