约定式提交
来源:约定式提交 1.0.0
为了保持清晰、可读的提交历史,遵循以下 Git Commit 规范。
提交信息格式
提交信息由三部分组成:
<type>(<scope>): <subject>
<body>
<footer><type>:提交类型(必填)<scope>:影响范围(可选)<subject>:简要描述提交内容(必填,50 字符以内)<body>:详细描述提交内容(可选)<footer>:补充信息,如BREAKING CHANGE或关联的 Issue(可选)
提交类型(Type)
| 类型 | 说明 |
|---|---|
| feat | 新功能 |
| fix | 修复 bug |
| docs | 文档修改 |
| style | 代码风格(不影响功能,如格式化) |
| refactor | 代码重构(不影响功能或修复 bug) |
| perf | 性能优化 |
| test | 测试相关 |
| chore | 其他,如构建过程或依赖管理 |
| revert | 回滚提交 |
影响范围(Scope)
<scope> 用于说明影响范围,例如:
core(核心功能)ui(用户界面)docs(文档)build(构建系统)
Body 和 Footer
Body(详细描述)
<body> 主要用于描述提交的详细信息,可以包含:
- 变更的原因
- 解决方案或实现方式
- 额外的背景信息
建议换行清晰描述,必要时可以使用列表。
Footer(补充信息)
<footer> 用于提供额外的信息,例如:
BREAKING CHANGE: 描述重大变更及影响- 关联的 Issue(如
Closes #123)
提交示例
添加新功能
feat(auth): 添加用户登录功能
新增了用户身份验证功能,支持用户名和密码登录。修复 bug
fix(api): 修复请求超时问题
修复了由于数据库查询未加索引导致的 API 响应超时问题。更新文档
docs(readme): 更新使用说明
补充了安装步骤,增加了示例代码。代码格式调整
style(config): 统一缩进为 2 空格
调整所有代码文件的缩进格式,确保一致性。代码重构
refactor(auth): refactor authentication logic
Optimized authentication module for better readability and maintainability.关联 Issue
fix(api): fix data loss issue
Resolved an issue where database transactions were not properly committed under high concurrency.
Closes #123重大变更
feat(db): update database schema
Modified table structure and added a new user role field.
BREAKING CHANGE: Requires database migration.