格式:
<type>(<scope>): <subject> [<ISSUE_ID>]
<body>
<footer>
例子:
feat(user): Add user registration [777]
Use Tencent cloud verification code to verify mobile phone
and add user registration function
https://github.com/one-user/a-project/issues/777
type [必須]
用于說(shuō)明 commit 的類(lèi)別,只允許使用下面幾種標(biāo)識(shí):
-
feat:新功能(feature) -
fix:修補(bǔ)bug -
docs:文檔(documentation) -
style: 格式(不影響代碼運(yùn)行的變動(dòng)) -
refactor:重構(gòu)(即不是新增功能,也不是修改bug的代碼變動(dòng)) -
perf:優(yōu)化 -
test:增加測(cè)試 -
chore:構(gòu)建過(guò)程或輔助工具的變動(dòng) -
revert:撤銷(xiāo)上一次的 commit
scope [必須]
用于說(shuō)明修改的范圍,基本上有有以下幾種情形:
-
all:表示大范圍的修改 -
loation:表示小范圍的修改 -
module:表示修改了某個(gè)模塊 例如:feat(user): add user login
subject [必須]
用于表示本次提交修改的簡(jiǎn)要說(shuō)明,盡量簡(jiǎn)短
ISSUE_ID [可選]
添加在 git issues 中需求或者 bug 修復(fù)對(duì)應(yīng)的 issues 記錄ID
body [可選]
body中就是 subject的詳細(xì)說(shuō)明
footer [可選]
可以寫(xiě)備注,填寫(xiě)相關(guān)的需求管理 issues id
commit-msg hook
如何保證每一次commit-msg信息格式的準(zhǔn)備,可以是使用commit-msg hook