Git提交信息規範

Git對程序員來說是再熟悉不過的了。但是很多程序員其實並沒有規範的使用git,最簡單的提交信息的內容其實就有很多人不注意。

一、git提交

我們用git提交代碼:

git commit -m "hello world" 。

我們現在說的就是"hello world" 怎麼書寫的規範。

"hello world" 就是我們常說的commit mesage。

上面代碼的-m參數,是用來指定 commit mesage 的。

這裡推薦使用目前使用最廣泛的 angular 規範。

二、規範內容

angular 規範的 commit message 包括 3 個部分 ,header 、body 和 footer 。

() : //空一行//空一行

type:

type 用於說明 commit 的類型,只允許使用下面 7 個標識

feat: 新功能(feature)

fix: 修補 Bug

docs: 文檔 (documention)

style: 樣式 (不影響代碼運行的變動)

refactor: 重構 (既不是新增功能,也不是修改 Bug 的代碼變動)

test: 增加測試

chore: 構建過程或輔助工具的變動

scope:

scope 用於說明 commit 影響的範圍,比如數據層、控制層、視圖層等,視項目不同而不同

subject 是 commit 目的的簡短描述,不超過 50 個字符

body 部分是對本次 commit 的詳細描述,可以分成多行

footer 部分只用於兩種情況

不兼容變動時,以 BREAKING CHANGE 開頭,後面是對變動的描述以及變動理由和遷移方法

如果當前 commit 針對某個 issue ,那麼可以在 footer 部分關閉這個 issue

例子:

feat: 新增分析師清理功能 分析師清理功能,包括 1. 查詢分析師 2. 分時段清理

fix: minor typos in code see the issue for details on the typos fixed fixes issue #12

Git提交信息規範


分享到:


相關文章: