commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCommit Changes
提交变更
Flags
可选参数
| Flag | Effect |
|---|---|
| Diff staged changes ( |
| Diff unstaged changes ( |
| Conventional commit message ( |
| Plain-English one-liner, no conventional formatting. |
| Run hooks. Off by default; without it, the commit passes |
No flags → , hooks skipped.
--staged --conventional| 参数 | 作用 |
|---|---|
| 对比已暂存的变更( |
| 对比未暂存的变更( |
| 生成符合规范的提交信息( |
| 生成纯英文单行提交信息,不使用规范格式。 |
| 执行钩子。默认关闭;不使用该参数时,提交会自动带上 |
无参数时默认启用,并跳过钩子。
--staged --conventionalDiff-only constraint
仅基于差异的约束
The diff is the only input for the message. Ignore conversation history, review
threads, ticket text, and stated rationale unless the same fact appears in the
diff. Never write "address review feedback", "as requested", or "implement the
plan". Describe the concrete change instead.
提交信息仅以代码差异作为输入。忽略对话历史、评审线程、工单文本及说明理由,除非这些内容的事实在差异中有所体现。绝对不要写入“处理评审反馈”“按要求修改”“执行计划”这类表述,而是要描述具体的变更内容。
Hook behavior
钩子行为
- Without : every
--verifycommand must includegit commit.-n - With : run hooks; never pass
--verifyor-n.--no-verify
If the commit fails, do not switch hook behavior unless the user changes the
flags and asks again.
- 不使用时:所有
--verify命令必须包含git commit参数。-n - 使用时:执行钩子;绝对不能添加
--verify或-n参数。--no-verify
如果提交失败,除非用户修改参数并再次请求,否则不要更改钩子行为。
-m
flag count
-m-m
参数数量
-mUse one or two flags, never three or more. First is the subject; an
optional second holds the entire body. Git inserts one blank line between
them, producing correct subject/body separation. Put all body bullets in that
single second , separated by (use ), never .
-m-m-m-m\n$'...'\n\nbash
git commit -n -m "feat: add auth flow" \
-m $'- Implement OAuth login\n- Add JWT handling'Three or more flags insert a blank line between every bullet. A single
with an embedded body gets bodies dropped. Both are wrong.
-m-m使用1个或2个参数,绝对不能使用3个及以上。第一个用于指定主题;可选的第二个用于填写完整正文。Git会在两者之间插入一个空行,实现主题与正文的正确分隔。将所有正文列表项放在单个第二个中,用分隔(使用语法),绝对不要用。
-m-m-m-m\n$'...'\n\nbash
git commit -n -m "feat: add auth flow" \
-m $'- Implement OAuth login\n- Add JWT handling'使用3个及以上参数会在每个列表项之间插入空行。单个参数中嵌入正文会导致正文被丢弃。这两种方式都是错误的。
-m-mStep 1: Diff the changes
步骤1:获取变更差异
- or default:
--stagedgit diff --cached | cat - :
--unstagedgit diff | cat
If empty, stop: "No changes found to commit."
- 使用或默认情况:
--stagedgit diff --cached | cat - 使用:
--unstagedgit diff | cat
如果差异为空,则停止操作:“未找到可提交的变更。”
Step 2: Analyze the diff
步骤2:分析差异
From the diff alone, identify changed files, change type, and what the diff
does: feature, fix, refactor, docs, test, chore, style, or perf.
仅从差异内容出发,识别变更的文件、变更类型以及差异实现的功能:新增功能(feature)、修复(fix)、重构(refactor)、文档(docs)、测试(test)、杂项(chore)、格式调整(style)或性能优化(perf)。
Step 3: Generate the message
步骤3:生成提交信息
Base the message solely on Step 2. Produce:
- : first line only.
subject - : optional; bullet lines joined by single
body.\n
For the chosen style, follow the exact format rules and examples in
, conventional rules for , simple rules for
. For , emit only.
./REFERENCE.md--conventional--simple--simplesubject完全基于步骤2的结果生成提交信息,需输出:
- :仅第一行内容。
subject - :可选内容;列表项用单个
body连接。\n
根据所选的格式,严格遵循中的格式规则和示例:使用时遵循规范格式,使用时遵循简单格式。使用时,仅输出。
./REFERENCE.md--conventional--simple--simplesubjectStep 4: Commit
步骤4:执行提交
Pass in the first , in a second when present.
subject-mbody-m- Without :
--verify. Confirmgit commit -n ...was present.-n - With :
--verify. Confirm neithergit commit ...nor-nwas present.--no-verify
将放入第一个参数,若存在则放入第二个参数。
subject-mbody-m- 不使用时:执行
--verify。需确认已包含git commit -n ...参数。-n - 使用时:执行
--verify。需确认未添加git commit ...或-n参数。--no-verify
Step 5: Report
步骤5:反馈结果
Report the message, diff scope, style, hook behavior, and the exact
command run.
git commit反馈提交信息、差异范围、格式类型、钩子行为以及执行的完整命令。
git commit