每次提交,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