1. 提交格式
每个提交消息由一个头、一个正文和一个页脚组成。 header有一个特殊的包含类型、范围和主题的格式。
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
1.1. type
| Type | Description |
|---|---|
| feat | A new feature |
| fix | A bug fix |
| docs | Documentation only changes |
| style: | Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) |
| refactor | A code change that neither fixes a bug nor adds a feature |
| perf | A code change that improves performance |
| test | Adding missing or correcting existing tests |
| build | Dependency-related content |
| ci | CI configuration related eg.changes to k8s, docker configuration files |
| chore | Changes to the build process or auxiliary tools and libraries such as documentation generation |
| revert | Rollback to the previous version |
1.2. scope
- scope 用于指定本次 commit 影响的范围(可省略)。
1.3. subject
- subject 是本次 commit 的简洁描述,长度约定在 50 个字符以内,通常遵循以下几个规范:
- 用动词开头,第一人称现在时表述,例如:change 代替 changed 或 changes
- 第一个字母小写
- 结尾不加句号(.)
1.4. Body
- body 是对本次 commit 的详细描述,可以分成多行。(body 可省略)
- 跟 subject 类似,用动词开头,body 应该说明修改的原因和更改前后的行为对比。
1.5.Footer
- 如果本次提交的代码是突破性的变更或关闭缺陷,则 Footer 必需,否则可以省略。
1.6.突破性的变更
- 当前代码与上一个版本有突破性改变,则 Footer 以 BREAKING CHANGE 开头,后面是对变动的描述、以及变动的理由。
1.7.关闭缺陷
- 如果当前提交是针对特定的
issue,那么可以在Footer部分填写需要关闭的单个issue或一系列issues。
1.8.可用scope
- Terminal(终端模块)
- CRUD(一键CRUD相关)
- baTable(通用表格)
- baInput(通用表单)
- install(安装)
- utils(工具)
- layout(布局)
- lang(语言包)
VS Code配置模板
1. 安装git-commit-plugin插件
2.插件默认配置
{
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"workbench.settings.applyToAllProfiles": [],
"editor.formatOnPaste": true,
"redhat.telemetry.enabled": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"prettier.requireConfig": true,
"prettier.useTabs": true,
"prettier.vueIndentScriptAndStyle": true,
"explorer.confirmDragAndDrop": false,
"extensions.ignoreRecommendations": true,
"explorer.confirmPasteNative": false,
"GitCommitPlugin.CustomCommitType": [
]
}
GitCommitPlugin.ShowEmoji:是否显示emoji表情,默认为true;
GitCommitPlugin.CustomCommitType: 定制提交类型,默认为null;
GitCommitPlugin.MaxSubjectCharacters:自定义主题的最大字数,默认为20。
GitCommitPlugin.Template:自定义git commit模板。
3. 使用
点击图标,选择commit type
- 选中
Scope这项,输入影响的范围; - 在选中
Subject选项,输入修改代码的描述; - 选中
Body选项,输入详情描述; - 选中
Footer选项,输入修复bug的链接; - 选中
Complete选项,进行信息的完成;
最后点击左侧的【提交】按钮进行git的提交。