work
done
請大家訂閱收藏加讚賞 <3
for adding human and machine readable meaning to commit messages
type
: 由下列選項擇一
build
(常用): Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)chore
: Updating grunt tasks etc; no production code change (means nothing that an external user would see)
- implementation (of an existing feature, which doesn't involve a fix),
- configuration (like the .gitignore or .gitattributes),
- private internal methods…
ci
: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)docs
(常用): Documentation only changesfeat
(常用): A new feature (this correlates with PATCH in semantic versioning[1])fix
(常用): A bug fix (this correlates with MINOR in semantic versioning)hotfix
:perf
(常用): A code change that improves performancerefactor
: A code change that neither fixes a bug nor adds a featurestyle
: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)test
(常用): Adding missing tests or correcting existing testsscope
: (optional)目前沒有統一的標準,通常會跟軟體開發方法而變
Scope could be anything specifying place of the commit change
init
runner
watcher
config
web-server
proxy
model
view
controller
description
: The subject contains a succinct description of the change
50字元的限制而是一個經驗法則。
讓標題保持在 50 字以下能夠確保標題的可讀性,並且強迫作者思考如何用更簡潔的方式表達發生什麼事情。
如果你很難總結出標題,這代表你可能在一個 commit 裏面做了太多的改變。請儘量讓 commits 單一化,一次只更動一個主題 (atomic commits)。
由於語言習慣問題,大家比較常使用指示性語句,來描述事實。為了避免這個問題,我們提供一個簡單的把戲來幫助大家完成正確的祈使句型
一個正確的 Git commit 標題應該要能夠代入下面的句型,使之成為完整的句子:
- If applied, this commit will <你的標題>
ex:
- If applied, this commit will update getting started documentation
- If applied, this commit will update getting started documentation
若不正確使用祈使句,會導致句子語意不通順
ex:- If applied, this commit will fixed bug with Y
- If applied, this commit will changing behavior of X
body
: (optional) more details than the description
include motivation for the change and contrasts with previous behavior
解釋"what"和"why"(改變了"什麼"和"為什麼"改變)
markdown
stylefooter
: (optional) only needed for two cases: break change
and close issue
break change
: All breaking changes have to be mentioned in footer with the description of the change, justification and migration notes. (this correlating with MAJOR
in semantic versioning)
BREAKING CHANGE: <description>
and follow a newline .The rest of the commit message is then used for this.close issue
: Closed issues should be listed on a separate line in the footer prefixed with Closes:
revert
: If the commit reverts a previous commit, it should begin with revert: , followed by the header of the reverted commit. In the body it should say: This reverts commit <hash>., where the hash is the SHA of the commit being reverted.
設定.gitmessage可產生範本,提醒大家遵守規範
1.建立template檔案
2.設定global參數
設定完成後對專案輸入commit
可發現commit message的預設內容為你設定的testtemplate
欲取消template,從~/.gitconfig文件中删除此部分即可(git config中刪除commit與core)
4.測試commit功能
commitlint可自動檢查commit message內容是否遵守規範
安裝方法如連結commitlint(尚未測試)