Google 的 Git commit 规范主要包括以下内容:
标题:必填,简洁明了地描述本次提交的内容,不超过 50 个字符。
内容:可选,具体说明本次提交的详细信息。
类型:必填,标明本次提交的类型。常见的类型有:
- feat: 新功能
- fix: 修复 bug
- docs: 文档更新
- style: 代码格式调整(不影响功能)
- refactor: 重构代码(既不是新增功能也不是修复 bug)
- test: 添加或修改测试用例
- chore: 其他修改(如构建流程、依赖管理等)
范围:可选,标明本次提交涉及到的模块或文件夹。
关键词:可选,标明本次提交与某个 issue 相关联。
下面是一个 Google 的 Git commit 规范举例:
feat(video): add support for multiple resolutions
This commit adds the ability to switch between different resolutions while watching a video.
Resolutions can be selected from a drop-down menu in the player controls.
Closes #1234
这个示例中,commit 标题为 “feat(video): add support for multiple resolutions”,表示添加了视频多分辨率支持。其中,“feat” 表示本次提交类型为新功能,“video” 表示涉及到视频模块。“Closes #1234” 则表示该 commit 关联了编号为 1234 的 issue。




