一個Git Commit Message模板
一個統一的commit訊息模板可以約束團隊成員使用一致的方式提交變更資訊,這樣也方便整合工具進行合規檢查。
通常來講,commit資訊應該包含如下內容:
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
type表示commit型別,可選值如下:
1.feat: A new feature
2.fix: A bug fix
3.docs: Documentation only changes
4.style: Changes that do not affect the meaning of the code (white-space, formatting, etc)
5.refactor: A code change that neither fixes a bug nor adds a feature
6.perf: A code change that improves performance
7.test: Adding missing tests or correcting existing tests
8.build: Changes that affect the build system or external dependencies (e.g: gulp, npm)
9.ci:Changes to our CI configuration files and scripts (e.g: Travis, Circle, BrowserStack)
10.chore: Other changes that don’t modify src or test files
11.revert: Reverts a previous commit
scope表示影響範圍,如:route, component, utils, build等
subject表示commit概述,建議符合50/72 formatting
body表示具體修改的內容,可以分為多行,每一行建議符合50/72 formatting
footer是一些備註資訊, 通常是BREAKING CHANGE或修復的BUG連結,如:issue #123
變更訊息模板可以通過檔案的方式固話下來,這樣在每次提交變更的時候參照模板填寫對應的資訊。
一個完整的模板內容如下:
# head: <type>(<scope>): <subject> # - type: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert # - scope: can be empty (eg. if the change is a global or difficult to assign to a single component), e.g: route, component, utils, build... # - subject: start with verb (such as 'change'), 50-character line # # body: 72-character wrapped. Multiple lines separated by “-”, This should answer: # * Why was this change necessary? # * How does it address the problem? # * Are there any side effects? # # footer: # - Include a link to the ticket, if any. # - BREAKING CHANGE # # e.g: # <type>(<scope>): <subject> # <BLANK LINE> # <body> # <BLANK LINE> # <footer> # # types: # # 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 tests or correcting existing tests # build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) # ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) # chore: Other changes that don't modify src or test files # revert: Reverts a previous commit
可以將上述模板資訊儲存在檔案"~/.gitmessage "中並新增為git的commit模板:
修改 ~/.gitconfig,新增:
[commit]
template = ~/.gitmessage
作者:程式設計隨筆
出處:http://www.cnblogs.com/nuccch/
宣告:本文版權歸作者和部落格園共有,歡迎轉載,但請在文章頁面明顯位置給出原文連線。