Skip to main content

Commit 规范

目标

规范开发者每次提交代码到远程仓库

提交信息结构

统一格式:

<type>(scope?): <short summary>

[optional body]

[optional footer(s)]
  • type:本次提交的类型(必填)
  • scope:影响范围(可选,比如模块名、包名)
  • short summary:一句话说明做了什么(必填)
  • body:必要时补充动机、实现思路(可选,多行)
  • footer:放关联 issue、BREAKING CHANGE 等(可选)

示例:

feat(api): add user login endpoint

Support JWT-based login and return user profile in response.

Closes #123

类型(type)约定

常用 6 个就够用:

  • feat:新增功能(feature)
  • fix:修复 bug
  • docs:文档调整(仅文档)
  • style:格式变动(不影响逻辑,如空格、格式化)
  • refactor:代码重构(不加新功能、不修 bug)
  • test:测试相关(新增/修改测试)
  • chore:杂项(构建、依赖、脚本、CI 配置等)
feat: add user profile page
fix: handle null user in login
docs: update installation guide
style: format code with prettier
refactor: extract auth middleware
test: add tests for user service
chore: bump typescript to 5.0

简短说明(summary)规则