GIt commit 規範
阿新 • • 發佈:2020-10-04
最近有幸參與到了一個開源專案的活動,看到別人提交的 commit 都很規範,自己的都是些什麼鬼?經過一番搜尋,發現網上很多都提到了 angularjs 的規範。
** 格式 **
Commit Message 格式
<type>(<scope>): <subject>
<空行>
<body>
<空行>
<footer>
分為 頁首、正文和頁尾。其中頁首包括了型別、範圍還有 subject。
type
型別 | 描述 |
---|---|
feat | 新增 feature |
fix | 修復bug |
docs | 僅僅修改了文件,比如 README... |
style | 修改了空格、格式縮排、逗號等,不改變程式碼邏輯 |
refactor | 程式碼重構,沒有加新功能或者修復bug |
perf | 優化相關,比如提升效能、體驗 |
test | 測試用例,比如單元測試、整合測試等 |
chore | 改變構建流程、或者增加依賴庫、工具等 |
revert | 回滾到上一個版本 |
scope
具體改動的檔案
subject
對正文的概括
body
just as in
includes motivation for the change and contrasts with previous behavior
footer
不相容變動
如果當前程式碼和上一個版本不相容,需要在這裡以 BREAKING CHANGE 開頭,後面接具體的描述
相關 issues
這裡是和變動相關的 issues。例如:
Closed bugs should be listed on a separate line in the footer prefixed with "Closes" keyword like this:
Closes #234
or in case of multiple issues:
Closes #123, #245, #992
工具
既然有標準了,那肯定就會有對應的工具來輔助人們寫 commit message,工具貌似還不少,我這裡使用 git-cz
在需要使用 git commit 的時候換成 git cz 就行了。
就像這樣
是不是很方便?
公眾號:沒有夢想的阿巧 後臺回覆 "群聊",一起學習,一起進步