git-commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit Commit
Git提交
Rules
规则
- Never add lines to commit messages
Co-Authored-By - Never mention Claude, AI, agent, copilot, or any automated tooling
- Commits must look like they were written by a human developer
- 绝对不要在提交信息中添加行
Co-Authored-By - 绝对不要提及Claude、AI、agent、copilot或任何自动化工具
- 提交信息必须看起来像是由人类开发者编写的
Format
格式
text
type(scope): subject
body (optional)- subject: lowercase, imperative mood, no period, max 72 chars
- body: wrap at 72 chars, explain why not what, separated by blank line
text
type(scope): subject
body (optional)- subject(主题):小写、祈使语气、无句号,最多72个字符
- body(正文):每行不超过72个字符,解释原因而非内容,与主题之间用空行分隔
Types
提交类型
| Type | Use for |
|---|---|
| New feature |
| Bug fix |
| Code change that neither fixes nor adds |
| Documentation only |
| Formatting, semicolons, no code change |
| Adding or updating tests |
| Build, tooling, deps, no production code |
| Performance improvement |
| CI/CD configuration |
| 类型 | 适用场景 |
|---|---|
| 新增功能 |
| 修复Bug |
| 既不修复Bug也不新增功能的代码变更 |
| 仅修改文档 |
| 格式调整(如分号),无代码逻辑变更 |
| 添加或更新测试用例 |
| 构建、工具、依赖更新,无生产代码变更 |
| 性能优化 |
| CI/CD配置变更 |
Scope
作用域
Derive the scope from the primary area of change:
- Module or package name (,
auth,api)db - Feature area (,
login,checkout)search - Layer (,
ui,server)cli
Omit scope only when the change is truly project-wide.
从主要变更区域推导作用域:
- 模块或包名称(、
auth、api)db - 功能区域(、
login、checkout)search - 层级(、
ui、server)cli
只有当变更真正涉及整个项目时,才可以省略作用域。
Workflow
工作流程
- Run and
git status(orgit diff --stagedif nothing staged)git diff - Identify the primary change type and scope
- Write the commit message
- Stage relevant files by name (avoid or
git add .)git add -A - Commit using a HEREDOC:
bash
git commit -m "$(cat <<'EOF'
type(scope): subject
optional body
EOF
)"- 运行和
git status(如果没有暂存文件则运行git diff --staged)git diff - 确定主要变更类型和作用域
- 编写提交信息
- 按文件名暂存相关文件(避免使用或
git add .)git add -A - 使用HEREDOC进行提交:
bash
git commit -m "$(cat <<'EOF'
type(scope): subject
optional body
EOF
)"Examples
示例
text
feat(auth): add password reset flow
Allow users to reset their password via email link.
Tokens expire after 30 minutes.text
fix(api): handle null response from payment gatewaytext
refactor(db): extract query builder into separate moduletext
chore(deps): upgrade react to v19text
feat(auth): add password reset flow
Allow users to reset their password via email link.
Tokens expire after 30 minutes.text
fix(api): handle null response from payment gatewaytext
refactor(db): extract query builder into separate moduletext
chore(deps): upgrade react to v19