Commit message
步驟
- 執行
git diff --staged 以檢視將要提交的內容。若無任何暫存變更,請告知使用者,並詢問是要暫存所有檔案(git add -A)還是特定檔案。切勿在未經詢問的情況下提交未暫存的工作。
- 執行
git log --oneline -15 並比對您看到的風格:Conventional Commits(feat(api): …)、工單前綴(ABC-123 …)或純文字句子。若無明確慣例,請使用純祈使句。
- 若暫存的變更涉及多項不相關的內容,建議先將其拆分為多次提交,再為所有變更撰寫一則訊息。
格式
<主旨行,祈使語氣,最多約 72 字元,結尾不加句點>
<主體:說明變更的原因以及審查者無法從 diff 中看到的任何資訊。
每行 72 字元。若是微小的變更,可略過主體。>
<結尾標記:Fixes #123、Co-authored-by: …、BREAKING CHANGE: …>
- 祈使語氣:使用「Add retry to upload」,而非「Added」或「Adds」。
- 主旨行說明使用者或程式碼庫發生了什麼變更,而非哪些檔案被修改。
- 主體解釋原因:錯誤、限制條件、您否決的替代方案。diff 已經顯示了內容。
- 若使用 Conventional Commits,請誠實選擇類型:
feat(新行為)、fix(錯誤)、refactor(無行為變更)、perf、docs、test、build、ci、chore。破壞性變更請加上 ! 以及 BREAKING CHANGE: 結尾標記。
範例
fix(auth): refresh the token before it expires, not after
Requests made in the last 30 seconds of a token's life failed with 401
because the refresh only ran on the first failure. Refresh when less than
60 seconds remain instead.
Fixes #482
Remove unused CSV export endpoint