關於網路那些事...

網路行銷,SEO,網路趨勢,教學文章,網頁設計,生活時事

Git 提交訊息樣式建議

Git 官方建議的提交訊息樣式,可以讓提交訊息更加容易理解及管理

原則上,可以將訊息分成三種型態

  • 類型:標題
  • 內容
  • 註解

類別

首先,在 commit 標題之前,建議要先清楚定義類別,定義方式有以下建議:

feature or feat 新功能

fix:修復錯誤

docs:文檔新增, 修改相關

style:格式修正(代碼無變動)

refactor:原有代碼重構

test:測試,測試重構(無變動到生產程式碼)

chore:任務相關,更新任務,程式包配置變動等(無變動到生產程式碼)

標題

標題建議在 50 字元之內,第一個字母大寫,並且最後不必加句號。
标题,使用直接表達命令、需求、禁止、勸告..的方式,少用或許,可能,或間接的方式表達

內容

正文內容只需要解釋目前提交的任務,原因即可,而不必說明方法。

寫內容時,要在標題和內容之間保留一行空白,並且每一行的內容控制在 72 字元內。

註解

註解可以用來描述問題的關鍵字,例如 用戶ID,問題特徵或注意事項等等。

每一個段落都以一行空白做區隔

如果有使用問題追蹤,可以在最後加上引用,例如:
解決問題:#123
詳見:#456, #789

底下則是 git commit 範例

feat: Summarize changes in around 50 characters or less

More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of the commit and the rest of the text as the body. The
blank line separating the summary from the body is critical (unless
you omit the body entirely); various tools like `log`, `shortlog`
and `rebase` can get confused if you run the two together.

Explain the problem that this commit is solving. Focus on why you
are making this change as opposed to how (the code explains that).
Are there side effects or other unintuitive consequenses of this
change? Here's the place to explain them.

Further paragraphs come after blank lines.

 - Bullet points are okay, too

 - Typically a hyphen or asterisk is used for the bullet, preceded
   by a single space, with blank lines in between, but conventions
   vary here

If you use an issue tracker, put references to them at the bottom,
like this:

Resolves: #123
See also: #456, #789

https://udacity.github.io/git-styleguide/


如果你喜歡我們的文章內容,請在這裡按個讚



最新文章推薦