git-commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Git Commit

Git 提交

Inspect

检查

  • Inspect
    git status
    and the relevant staged/working diffs before writing anything.
  • Detect the actual change from the diff; do not guess from open tabs or filenames only.
  • Exclude files the user explicitly says not to commit or not to include in the message.
  • 先检查
    git status
    以及相关的暂存区/工作区差异,再进行任何编写操作。
  • 从差异中检测实际变更内容;不要仅根据打开的标签页或文件名猜测。
  • 排除用户明确说明不提交或不纳入消息的文件。

Pick Command Shape

选择命令格式

  • Use one line for one coherent intent, even when it touches several files.
  • Use one line for focused updates such as one UI behavior change, repeated CSS cleanup, or one variable/API rename.
  • Use a detailed commit for multiple independent intents, risky behavior changes, migrations, broad feature work, or context future readers need.
  • 若变更为单一连贯意图,即使涉及多个文件,也使用单行格式。
  • 针对聚焦型更新(如单一UI行为变更、重复的CSS清理、单一变量/API重命名)使用单行格式。
  • 若包含多个独立意图、高风险行为变更、迁移工作、广泛的功能开发,或未来阅读者需要相关上下文,则使用详细提交格式。

Subject

主题

  • Treat the first
    -m
    as the commit subject. It must summarize the whole commit.
  • For one-line commits, use Conventional Commits:
    type(scope): concise summary
    .
  • For detailed commits, use a plain-English overall subject without
    type(scope)
    .
  • Keep detailed subjects readable in
    git log --oneline
    , for example
    Add passkey authentication support
    .
  • Prefer imperative mood when natural.
  • 将第一个
    -m
    参数作为提交主题,必须概括整个提交内容。
  • 单行提交需遵循Conventional Commits规范:
    type(scope): concise summary
  • 详细提交的主题使用通俗易懂的英文表述,无需
    type(scope)
    格式。
  • 确保详细提交的主题在
    git log --oneline
    中可读性良好,例如
    Add passkey authentication support
  • 自然情况下优先使用祈使语气。

Body

正文

  • Add a body only when it helps explain why the change was needed and what changed.
  • Use a second
    -m
    argument for the body.
  • Use literal newlines for paragraphs and bullets.
  • Write the body paragraph in descriptive English.
  • 仅当有助于解释变更原因和变更内容时才添加正文。
  • 使用第二个
    -m
    参数传递正文内容。
  • 使用字面换行符分隔段落和项目符号。
  • 正文段落使用描述性英文书写。

Monorepos

单仓架构(Monorepo)

  • If the repo is a monorepo or the diff spans apps/packages, prefer scoped body bullets:
    type(scope): specific change
    .
  • Use concrete scopes from affected apps/packages/domains, such as
    admin
    ,
    server
    ,
    website
    ,
    docs
    , or
    shared
    .
  • Do not use vague labels like
    Both
    ,
    Frontend
    , or
    Backend
    when concrete scopes exist.
  • Sort scoped bullets by type, then scope, then importance.
  • Prefer this type order:
    feat
    ,
    fix
    ,
    refactor
    ,
    perf
    ,
    test
    ,
    docs
    ,
    style
    ,
    chore
    .
  • 若仓库为monorepo或差异涉及多个应用/包,优先使用带范围的项目符号格式:
    type(scope): specific change
  • 使用受影响的应用/包/领域的具体范围,例如
    admin
    server
    website
    docs
    shared
  • 当存在具体范围时,避免使用
    Both
    Frontend
    Backend
    这类模糊标签。
  • 按类型、范围、重要性对带范围的项目符号排序。
  • 优先遵循以下类型顺序:
    feat
    fix
    refactor
    perf
    test
    docs
    style
    chore

Single Repos

单仓库

  • For single-repo detailed commits, plain body bullets are fine.
  • Keep bullets specific and ordered by importance.
  • 单仓库的详细提交使用普通项目符号格式即可。
  • 项目符号需具体,并按重要性排序。

Guardrails

约束规则

  • Return only a ready-to-run
    git commit
    command.
  • Do not include a
    git add
    command.
  • Do not run the commit unless explicitly asked.
  • Do not add AI or agent co-author lines.
  • 仅返回可直接运行的
    git commit
    命令。
  • 不要包含
    git add
    命令。
  • 除非明确要求,否则不要执行提交操作。
  • 不要添加AI或Agent合著者行。

Templates

模板

One-line:
bash
git commit -m "type(scope): concise overall summary"
Detailed monorepo:
bash
git commit -m "Plain-English overall summary" -m "Describe the problem or motivation and what the full commit changes in normal English.

- type(scope): first specific change
- type(scope): second specific change
- type(scope): third specific change"
Detailed single-repo:
bash
git commit -m "Plain-English overall summary" -m "Describe the problem or motivation and what the full commit changes in normal English.

- type(scope): first specific change
- type(scope): second specific change
- type(scope): third specific change"
NOTE: you must give the git commit format inside
bash {...determined git commit format}
, do not give raw text. becuase output will be copied and pasted in terminal
单行格式:
bash
git commit -m "type(scope): concise overall summary"
详细单仓架构格式:
bash
git commit -m "Plain-English overall summary" -m "Describe the problem or motivation and what the full commit changes in normal English.

- type(scope): first specific change
- type(scope): second specific change
- type(scope): third specific change"
详细单仓库格式:
bash
git commit -m "Plain-English overall summary" -m "Describe the problem or motivation and what the full commit changes in normal English.

- type(scope): first specific change
- type(scope): second specific change
- type(scope): third specific change"
注意:必须将git commit格式放在
bash {...determined git commit format}
中,不要返回纯文本。因为输出内容将被复制粘贴到终端中