Conventional Commits
一句话解释
约定式提交是一种提交信息规范,使自动变更日志与语义化版本成为可能。
用大白话说
约定式提交是一种以结构化格式书写提交信息的约定:type(scope): description。type(feat、fix、docs、style、refactor、perf、test、chore)指示变更类型,可选 scope 命名受影响区域,description 是简短摘要。例如 "feat(auth): add OAuth login" 在 auth 范围添加功能,而 "fix(parser): handle empty input" 是 bug 修复。脚注带 BREAKING CHANGE: 或 type 后加 ! 标记破坏性变更。正文与脚注提供细节。价值在于自动化:工具可解析这些信息自动生成变更日志、决定下次语义版本提升(feat→minor、fix→patch、BREAKING→major)并按类型分组变更。Angular、semantic-release 工具及许多库采用此约定。
示例
bash
# Feature commit
feat(auth): add OAuth2 login flow
# Bug fix
fix(parser): handle empty input without crashing
# Breaking change (note the !)
feat(api)!: rename getUser to fetchUser
BREAKING CHANGE: getUser is now fetchUser
# Docs only
docs(readme): update installation stepstype(scope): description。feat→minor、fix→patch、! 或 BREAKING CHANGE→major。工具解析以生成变更日志与版本提升。
相关术语
相关资源
相关课程
- 提交实践
学习约定式提交。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。