commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Write every commit in Conventional Commits format:
<type>(scope): <description>
, then an optional body and footer.
所有提交均需采用 Conventional Commits 格式:
<type>(scope): <description>
,之后可选择性添加正文和页脚。

Steps

步骤

  1. Read the diff. Run
    git status
    and
    git diff --staged
    (fall back to
    git diff
    when nothing is staged).
  2. Classify. Choose the
    type
    (
    feat
    ,
    fix
    ,
    docs
    ,
    style
    ,
    refactor
    ,
    perf
    ,
    test
    ,
    build
    ,
    ci
    ,
    chore
    ,
    revert
    ), the
    scope
    (the affected area, omitted when the change is broad), and a
    description
    — one imperative-mood line under 72 characters. Each of the three must trace to a specific change in the diff. If the diff holds more than one unrelated change, commit them separately.
  3. Compose. Assemble the subject line. Add a body — the why, and what a reader can't see from the diff — when the change isn't self-evident, and a footer (
    Closes: <id>
    ,
    Refs: <id>
    ) when an issue applies. Signal a breaking change with
    !
    (
    feat(api)!: require verified email
    ), or a
    BREAKING CHANGE:
    footer when the break needs explaining.
  4. Commit. Stage the intended files — if they contain secrets or credentials, stop and flag it instead. Run
    git commit
    and let hooks run; if one fails, fix the cause or report it.
Rewriting shared history or bypassing checks —
--force
,
reset --hard
,
--no-verify
,
git config
edits — happens only when the user explicitly asks.
  1. 查看diff。 运行
    git status
    和
    git diff --staged
    (若无暂存内容,则改用
    git diff
    )。
  2. 分类。 选择
    type
    (可选值:
    feat
    、
    fix
    、
    docs
    、
    style
    、
    refactor
    、
    perf
    、
    test
    、
    build
    、
    ci
    、
    chore
    、
    revert
    )、
    scope
    (受影响范围,若变更涉及面广则省略)以及
    description
    ——一行祈使句,长度不超过72个字符。这三部分都必须对应diff中的具体变更。如果diff包含多个不相关的变更,需分开提交。
  3. 撰写。 组装主题行。当变更不言自明时无需添加额外内容,否则补充正文——说明变更的_原因_,以及读者从diff中无法得知的信息;如果关联了issue,添加页脚(
    Closes: <id>
    、
    Refs: <id>
    )。使用
    !
    标记破坏性变更(示例:
    feat(api)!: require verified email
    ),如果破坏性变更需要详细说明,添加
    BREAKING CHANGE:
    页脚。
  4. 提交。 暂存目标文件——如果文件包含密钥或凭证,立即停止并标记问题。运行
    git commit
    并让钩子正常执行;若有钩子执行失败,修复原因或上报。
重写共享历史或绕过检查的操作——包括
--force
、
reset --hard
、
--no-verify
、修改
git config
——仅在用户明确要求时执行。