Git Commit 提交规范
本规范适用于所有参与项目开发的开发者以及文档编写者,旨在确保代码提交的可读性和一致性。采用 约定式提交 (Conventional Commits),所有 commit message 统一遵循格式:
<type>(<scope>): <subject>[可选正文,详细描述改动][可选脚注]字段说明 / Field Description
Section titled “字段说明 / Field Description”1. type (必填 / required)
Section titled “1. type (必填 / required)”feat: 新增业务功能、特性 / Add new business featuresfix: 修复程序 Bug / Fix program bugsdocs: 仅文档修改(md/mdx、注释、说明文档) / Documentation‑only changesstyle: 格式调整,空格、换行、样式;不修改业务逻辑 / Format adjustments, no business‑logic changesrefactor: 代码重构,无新功能、无 Bug 修复 / Code refactoring, no new features and no bug fixesperf: 性能优化 / Performance optimizationtest: 新增/修改单元测试、集成测试 / Add or modify unit / integration testschore: 构建脚本、CI、依赖版本更新,业务代码无改动 / Build scripts, CI, dependency updates
⚠️ type 全部小写,禁止使用
fixed、FEAT。Alltypevalues must be lowercase. Do NOT usefixed,FEAT.
2. scope (选填 / optional)
Section titled “2. scope (选填 / optional)”标记改动所属模块,示例 / Examples:permission、user、table、auth
3. subject (必填 / required)
Section titled “3. subject (必填 / required)”简短描述改动内容,小写开头,句尾不要加句号。Short description, start with lowercase, no trailing period.
✅ 提交示例 / Valid Examples
Section titled “✅ 提交示例 / Valid Examples”feat (user): 新增用户登录接口 /add user login apifix (auth): 修复密码加密算法错误 /fix password encryption algorithm errordocs (user): 更新用户注册流程说明文档 /update user registration process documentationstyle (auth): 优化密码输入框样式 /optimize password input box stylerefactor (table): 重构表格组件,提高性能 /refactor table component, improve performancetest (auth): 新增用户登录接口单元测试 /add user login api unit testchore (auth): 更新密码加密算法版本 /update password encryption algorithm version✅ 完整提交示例(改动较大、带详细 Body)
Section titled “✅ 完整提交示例(改动较大、带详细 Body)”适用于文档重构、多处调整、功能迭代等大幅改动场景:
docs (permission): 优化权限矩阵表格结构与适配体验
- 移除报错的 colgroup 标签,完全兼容 MDX 编译规则
- 表格外层增加横向滚动容器,解决小屏挤压错乱问题
- 底部说明行使用 colspan 整行跨列展示,去除冗余空单元格
- 统一各列最小宽度,固定短列不换行、长列自动折行
❌ 禁止写法 / Invalid Examples
Section titled “❌ 禁止写法 / Invalid Examples”修复 bug /fix bugfeat:新增某某功能fixed: xxxFEAT: xxx协作约定 / Collaboration Rules
Section titled “协作约定 / Collaboration Rules”- 一次 commit 只处理一件事,不要混合多种类型改动。
- 改动较大时,填写 body 正文,空一行后罗列修改要点。
- PR/MR 标题同样遵守该规范,便于代码评审与自动生成变更日志。