Commit Message Guide

Posted on Apr 19, 2025

基本格式

<type>(<scope>): <subject>
  • type:见下表。
  • scope:可选,小写短横线分隔,详见下一节。
  • subject:≤ 50 chars,祈使语气(add / fix / switch 等)。

为本博客项目提供最小可行的 Git 提交规范,聚焦 Header 一行,避免冗长。


Scope 说明

  • 可选字段:当改动局限于单一模块、包、目录或 UI 组件时填写;全局或多模块改动可省略。
  • 命名约定:全部小写,使用短横线分隔多词,例如 api, auth, db-migration, post-card
  • 来源参考
    • Mono‑repo 中的 package/name
    • 源码顶级目录,如 docs, scripts
    • 领域驱动名词,如 checkout, user-profile
    • UI 组件名,如 navbar, editor-toolbar
  • 长度建议:≤ 15 字符,保持稳定,不随任务编号或日期变化。
  • 示例
feat(editor): add live preview panel
fix(api-auth): refresh token expiry logic
chore: bump prettier config

Type 速查表

type 用途 例子
feat 新功能 feat(api): add v2 upload endpoint
fix 缺陷修复 fix(ui): correct avatar overlap
docs 文档 docs(readme): add setup section
style 格式 / 样式 style(css): prettify headings
refactor 重构 refactor(core): extract parser
perf 性能 perf(db): add index on slug
test 测试 test(api): add upload e2e
build 构建 build: bump hugo to 0.125.4
ci CI ci(github): cache go modules
chore 杂项 chore(config): switch image CDN
revert 回滚 revert: chore(config): switch image CDN

快速示例

chore(config): switch image CDN to cdn.gocowu.com

保持简洁,专注代码。