Git commit message格式規(guī)范(推薦)
<type>(<scope>): <subject>
<BLANK LINE> 空格
<body>
<BLANK LINE> 空格
<footer>
type(必須) :
用于說(shuō)明git commit的類別毙籽,只允許使用下面的標(biāo)識(shí)
- feat:新功能(feature)详拙。
- fix/to:修復(fù)bug
- docs:文檔(documentation)徽龟。
- style:格式(不影響代碼運(yùn)行的變動(dòng))疑俭。
- refactor:重構(gòu)(即不是新增功能几蜻,也不是修改bug的代碼變動(dòng))姻锁。
- perf:優(yōu)化相關(guān)寞冯,比如提升性能渴析、體驗(yàn)。
- test:增加測(cè)試吮龄。
- chore:構(gòu)建過(guò)程或輔助工具的變動(dòng)俭茧。
- revert:回滾到上一個(gè)版本。
- merge:代碼合并漓帚。
- sync:同步主線或分支的Bug母债。
scope(可選) :
scope用于說(shuō)明 commit 影響的范圍,比如數(shù)據(jù)層尝抖、控制層毡们、視圖層等等,視項(xiàng)目不同而不同昧辽。
例如在Angular衙熔,可以是location,browser搅荞,compile红氯,compile,rootScope咕痛, ngHref痢甘,ngClick,ngView等茉贡。
如果你的修改影響了不止一個(gè)scope塞栅,你可以使用*代替。
subject(必須) :
subject是commit目的的簡(jiǎn)短描述腔丧,不超過(guò)50個(gè)字符(超過(guò)可以再body 里進(jìn)行說(shuō)明)构蹬。
- 建議使用中文(感覺(jué)中國(guó)人用中文描述問(wèn)題能更清楚一些)。
- 結(jié)尾不加句號(hào)或其他標(biāo)點(diǎn)符號(hào)悔据。
body(可選) :
改動(dòng)的動(dòng)機(jī),詳細(xì)描述等
footer (可選) :需求鏈接狀態(tài)變化 (Closes #392)
這樣規(guī)范git commit到底有哪些好處呢俗壹?
- 便于程序員對(duì)提交歷史進(jìn)行追溯科汗,了解發(fā)生了什么情況。
- 一旦約束了commit message绷雏,意味著我們將慎重的進(jìn)行每一次提交头滔,不能再一股腦的把各種各樣的改動(dòng)都放在一個(gè)git commit里面怖亭,這樣一來(lái)整個(gè)代碼改動(dòng)的歷史也將更加清晰。
- 格式化的commit message才可以用于自動(dòng)化輸出Change log坤检。
Examples :
feat($browser): onUrlChange event (popstate/hashchange/polling)
Added new event to $browser:
forward popstate event if available
forward hashchange event if popstate not available
do polling when neither popstate nor hashchange available
Closes #1213242
fix($compile): couple of unit tests for IE9
Older IEs serialize html uppercased, but IE9 does not...
Would be better to expect case insensitive, unfortunately jasmine does
not allow to user regexps for throw expectations.
Closes #17116
參考 :
angularJS :
https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines