我一般這樣寫:

修復/新增/...(某功能): 主要的大標題,做了什麼,一句話概括
  - 詳細描述01
  - 詳細描述02
    (或者一整段詳細描述)

換為英文大概就是:

fix/feat/...(api/auth/...): fix auth middleware 401 error
  - Fixed an issue where incorrect naming in the middleware prevented it from being referenced correctly.
  - The sequence was incorrect in some places, so those have been fixed as well.
  - The document has been updated.

好了,你已經可以寫一個規範的 commit message了 ——


進一步說明&&學習

實際上,有一個類似公式的東西,請參考

類型(範圍): 扼要
  正文(可選)
type(scope): summary
  body(optional)

例如:

fix(auth): handle expired login token
feat(profile): add avatar upload
docs(readme): update setup instructions
refactor(api): simplify error handling
test(cart): add checkout edge cases

Commit Message 實際上並無正確錯誤之分,但是按照上面的規範寫,無論如何都比你直接寫

修復了一個問題(fix bug) / xx代碼有所更新(xx Code Update)

要好得多。

常用的 Type

-------------------------------
常用:
-------------------------------
feat      新增
fix       修復
docs      文檔
style     格式調整,不影響邏輯
-------------------------------

Dontalk . Blog (Dontalk.org)

-------------------------------
偶爾:
-------------------------------
refactor  重構,不新增功能也不修 bug
test      測試
chore     雜項維護,例如依賴、設定
perf      效能改善
ci        CI/CD 設定
build     建置系統或打包相關
revert    回退提交
-------------------------------