每次提交,Commit message 都包括包括三个字段:type(必需)、scope(可选)和 subject(必需)。node
type 用于说明 commit 的类别,只容许使用下面9个标识。git
scope 用于说明 commit 影响的范围,好比数据层、控制层、视图层等等,视项目不一样而不一样github
subject 是 commit 目的的简短描述,不超过50个字符。npm
Body 部分是对本次 commit 的详细描述,能够分红多行。下面是一个范例。ruby
More detailed explanatory text, if necessary. Wrap it to
about 72 characters or so.
Further paragraphs come after blank lines.
- Bullet points are okay, too
- Use a hanging indent
复制代码
确保本身环境已安装 Node, 本次主要依赖两个 Node 工程,npm install -g commitizen
全局安装 commitizen 工程。 npm i -g cz-customizable
全局安装 cz-customizable 工程。 同时在~/ 或项目目录下建立 .cz-config.js 文件, 拷贝下面代码到该文件。bash
'use strict';
module.exports = {
types: [
{
value: 'WIP',
name : '💪 WIP: Work in progress'
},
{
value: 'feat',
name : '✨ feat: A new feature'
},
{
value: 'fix',
name : '🐞 fix: A bug fix'
},
{
value: 'refactor',
name : '🛠 refactor: A code change that neither fixes a bug nor adds a feature'
},
{
value: 'docs',
name : '📚 docs: Documentation only changes'
},
{
value: 'test',
name : '🚨 test: Add missing tests or correcting existing tests'
},
{
value: 'chore',
name : '🗯 chore: Changes that don\'t modify src or test files. Such as updating build tasks, package manager'
},
{
value: 'style',
name : '💅 style: Code Style, Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)'
},
{
value: 'revert',
name : '⏪ revert: Revert to a commit'
}
],
scopes: [],
allowCustomScopes: true,
allowBreakingChanges: ["feat", "fix"]
};
复制代码
删除 cz-customizable 工程中 questions.js 中 关于 footer 部分,认为暂时不须要(也能够注释掉,后续须要再加回来)。ide
上述共工做完成后,使用git cz 代替 git commit 提交你的代码。工具
ruby china 关于如何写好 message
github.com/leonardoana…
github.com/angular/ang…
阿里南京技术专刊post