目前不少項目都是經過 Git 進行管理的,Git 每次提交代碼的過程當中 提交說明 commit message 是必須的。但僅僅必須是不夠的,好的提交說明能夠幫助咱們提升項目的總體質量。git
提交說明最首要的目的是幫助 提交者 說明本次提交的目的,而規範的說明信息有幾個好處。github
git commit
上增長 -m <msg>
或者 --message=<msg>
參數,而須要單獨寫提交信息好的提交說明要包含下面的內容:shell
Angular 主要有三個格式,其中 Head 是必須的,body 和 footer 是可選的。segmentfault
# head: <type>(<scope>): <subject> # - type: feat, fix, docs, style, refactor, test, chore # - scope: can be empty (eg. if the change is a global or difficult to assign to a single component) # - subject: start with verb (such as 'change'), 50-character line # # body: 72-character wrapped. 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 #
其中 type 用來講明 commit 的類別,只容許使用下面的 7 個標識。app
若是 type 爲 feat 和 fix ,則該 commit 信息將確定出如今 change log 之中。ide
scope 用於說明 commit 影響的範圍,好比影響哪一層、哪一個包中的內容或者使用哪些方案的實例。工具
subject 是關於 commit 信息的簡短描述,不超過 50 個字。性能
Body 部分是針對本次 commit 的詳細描述,能夠多行,要表達清楚變更的動機、與以前行爲的對比。測試
用於不兼容變更和關閉 Issue 。this
雖然純文字的提交說明已經很是明確了,可是卻比較單調,並且在一些內容上感受少了一些步驟,因而在現有的內容上進行少許的修改以更美觀的清晰。
type 主要將原來的 chore 進行了拆分,增長了 ci 和 review 兩個內容,用來補充項目開發過程當中的流程。其它的還有一些內容,能夠參照 gitemoji 。
:sparkles:
✨:bug:
🐛:memo:
📝:art:
🎨:recycle:
♻:white_check_mark:
✅:construction_Worker:
👷:ok_hand:
👌:zap:
⚡使用 git log 查詢的時候,看到的內容比較簡單,能夠經過下面的命令將信息格式化輸出。
alias lg="git log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(red)%h%C(r) —— %C(bold blue)%an%C(r): %C(white)%s%C(r) %C(dim white) %C(bold green)(%ar)%C(r) %C(bold yellow)%d%C(r)' --all"
使用命名查詢的效果以下:
文章首發於:https://www.zucchiniy.cn