git commit 规范

以下是 Conventional Commits 中最常用的一些类型,它们大多源自 Angular 团队的提交规范

类型 (Type) 含义 (Meaning) 示例
feat 新功能 (feature) feat: allow users to upload avatars
fix 修复 Bug (bug fix) fix: prevent memory leak when closing modal
docs 文档 (documentation) 的变更 docs: update installation guide
style 代码格式的变更 (不影响代码运行的变动,如空格、分号) style: format code with Prettier
refactor 代码重构 (既不是新增功能,也不是修复 bug 的代码变动) refactor: simplify user authentication logic
perf 性能优化 (performance) 的代码更改 perf: improve image loading speed by using lazy loading
test 增加或修改测试 test: add unit tests for user service
build 影响构建系统或外部依赖的更改 (如 gulp, broccoli, npm) build: update webpack to version 5
ci 影响CI 配置文件和脚本的更改 (如 Travis, Circle, GH Actions) ci: fix deployment script for production environment
chore 其他不修改 src 或 test 文件的更改 (如上所述) chore: add .editorconfig
revert 回退之前的提交 revert: feat: add ‘remember me’ checkbox (后面跟要回退的提交)
<type>(<scope>): <short summary>
│ │ │
│ │ └─⫸ Summary in present tense. Not capitalized. No period at the end.
│ │
│ └─⫸ Commit Scope: animations|bazel|benchpress|common|compiler|compiler-cli|core|
│ elements|forms|http|language-service|localize|platform-browser|
│ platform-browser-dynamic|platform-server|router|service-worker|
│ upgrade|zone.js|packaging|changelog|docs-infra|migrations|
│ devtools

└─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|test

注意:如果一次提交引入了不兼容的 API 变更,需要在类型/范围后面用 ! 标记,表示破坏性变更 (BREAKING CHANGE)。这对于版本管理至关重要。