commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCommit
提交
Write a commit message from the staged changes only, then commit.
仅根据 已暂存(staged) 的更改编写提交信息,然后提交。
Steps
步骤
- Inspect state — run these together:
git status --shortgit diff --staged --stat- (if huge, read the stat plus diffs of the most important files)
git diff --staged - (match the repo's existing style)
git log --format='%s' -n 20
- If nothing is staged, stop and tell the user. Do not unless they asked.
git add -A - Understand why the change was made, not just what lines moved. Group the diff into one logical change; if the staged diff clearly contains several unrelated changes, say so and suggest splitting.
- Draft the message and show it to the user in a fenced code block. Stop there — do not commit yet. Ask them to approve, or reply with edits.
- Never run in the same turn as the draft, not even with
git commitas a substitute for asking.--dry-run - If they request changes, redraft and ask again.
- Never run
- Only after the user approves, commit with (repeated
git commit -m "..."for body/footer).-m - Report the resulting briefly.
git log -1 --stat
- 检查状态 —— 一起运行以下命令:
git status --shortgit diff --staged --stat- (如果内容很大,阅读 stat 以及最重要文件的 diff)
git diff --staged - (匹配仓库现有的风格)
git log --format='%s' -n 20
- 如果没有已暂存的内容,停下来并告知用户。除非用户要求,否则不要执行 。
git add -A - 理解更改的原因,而不只是哪些行发生了变动。将 diff 归为一个逻辑变更;如果暂存的 diff 明显包含多个不相关的更改,请说明并建议拆分。
- 起草提交信息,并以围栏代码块的形式展示给用户。到此为止 —— 先不要提交。 请用户批准,或回复修改意见。
- 绝不要在起草信息的同一轮对话中运行 ,即使是
git commit也不能替代用户的确认。--dry-run - 如果用户要求修改,请重新起草并再次确认。
- 绝不要在起草信息的同一轮对话中运行
- 只有在用户批准后,才使用 提交(正文/页脚可重复使用
git commit -m "...")。-m - 简要报告执行后的 结果。
git log -1 --stat
Format
格式
<type>(<optional scope>): <subject>
- <optional body, max 3 bullets, one line each — why, not what>
<optional footer — BREAKING CHANGE: ..., Refs #123>Types: , , , , , , , , , ,
featfixrefactorperfdocsstyletestbuildcichorerevertSubject rules
- Imperative mood: "add", "fix", "remove" — not "added"/"adds".
- Lowercase start, no trailing period, ≤ 50 chars (hard cap 72).
- Say the effect, not the file list. Bad: . Good:
update CommentSelectRow.vue.filter comments by asset when attaching to a DF - Scope = the affected area (module, feature, package), only if it adds clarity.
Body — keep it short; most commits don't need one
- Default to no body. Add one only when the subject can't carry the why.
- Point form only: bullets, never prose paragraphs.
- - Max 3 bullets. One line each (≤ 72 cols) — if a bullet wraps, cut it down.
- Say the reason or the catch, not a summary of the diff. The diff is already in the commit.
- Don't list files, don't enumerate everything the change touches.
Footer
- for incompatible changes (or
BREAKING CHANGE: <description>after the type/scope).! - Issue refs: ,
Refs #123.Fixes #123
<type>(<optional scope>): <subject>
- <optional body, max 3 bullets, one line each — why, not what>
<optional footer — BREAKING CHANGE: ..., Refs #123>类型: 、、、、、、、、、、
featfixrefactorperfdocsstyletestbuildcichorerevert主题规则
- 使用祈使语气:"add"、"fix"、"remove" —— 不要用 "added"/"adds"。
- 小写字母开头,结尾不加句号,≤ 50 个字符(硬上限 72)。
- 说明影响,而不是文件列表。错误示例:。正确示例:
update CommentSelectRow.vue。filter comments by asset when attaching to a DF - 范围(scope)= 受影响的区域(模块、功能、包),仅在能增加清晰度时使用。
正文 —— 保持简短;大多数提交不需要正文
- 默认不写正文。只有主题无法承载原因时才添加。
- 仅使用要点形式:项目符号,不要用散文段落。
- - 最多 3 条要点。每行一条(≤ 72 列)——如果一条要点换行,就把它缩短。
- 说明原因或注意事项,而不是 diff 的摘要。diff 已经包含在提交中了。
- 不要列出文件,不要枚举更改涉及的所有内容。
页脚
- 不兼容变更使用 (或在类型/范围后加
BREAKING CHANGE: <描述>)。! - 问题引用:、
Refs #123。Fixes #123
Rules
规则
- Always get explicit approval on the drafted message before committing. No exceptions, even for a one-line trivial change.
- Never invent a ticket number, cause, or intent not visible in the diff or conversation.
- Never mention tooling that produced the change unless the user asks.
- Don't add co-author or generated-by trailers unless the repo/user requires it.
- If the repo's history clearly uses a different convention, follow the repo.
- 提交前必须获得用户对草稿信息的明确批准。 没有例外,即使是一行的小改动。
- 绝不虚构在 diff 或对话中看不到的工单号、原因或意图。
- 除非用户要求,否则不提产生该更改的工具。
- 除非仓库/用户要求,否则不添加 co-author 或 generated-by 尾部信息。
- 如果仓库历史明显使用不同的约定,请遵循该仓库的约定。
Examples
示例
fix: prevent duplicate asset rows in comment picker
- Dedupe ran before the asset filter, so one asset per linked deal.
- Now keyed on reference id.
Fixes #482refactor(queue): move retry config out of the job classesfeat(auth)!: require MFA for admin logins
BREAKING CHANGE: existing admin sessions are invalidated on deploy.fix: prevent duplicate asset rows in comment picker
- Dedupe ran before the asset filter, so one asset per linked deal.
- Now keyed on reference id.
Fixes #482refactor(queue): move retry config out of the job classesfeat(auth)!: require MFA for admin logins
BREAKING CHANGE: existing admin sessions are invalidated on deploy.