commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCommit
提交
Goals
目标
- Produce a commit that reflects the actual code changes and the session context.
- Follow common git conventions (type prefix, short subject, wrapped body).
- Include both summary and rationale in the body.
- 生成能反映实际代码变更和会话上下文的Commit。
- 遵循通用的Git规范(类型前缀、简短主题、换行的正文)。
- 在正文中同时包含变更摘要和变更依据。
Inputs
输入
- Codex session history for intent and rationale.
- ,
git status, andgit difffor actual changes.git diff --staged - Repo-specific commit conventions if documented.
- 用于了解意图和依据的Codex会话历史记录。
- 用于查看实际变更的、
git status和git diff输出。git diff --staged - 仓库文档中规定的特定Commit规范(如有)。
Steps
步骤
- Read session history to identify scope, intent, and rationale.
- Inspect the working tree and staged changes (,
git status,git diff).git diff --staged - Stage intended changes, including new files () after confirming scope.
git add -A - Sanity-check newly added files; if anything looks random or likely ignored (build artifacts, logs, temp files), flag it to the user before committing.
- If staging is incomplete or includes unrelated files, fix the index or ask for confirmation.
- Choose a conventional type and optional scope that match the change (e.g.,
,
feat(scope): ...,fix(scope): ...).refactor(scope): ... - Write a subject line in imperative mood, <= 72 characters, no trailing period.
- Write a body that includes:
- Summary of key changes (what changed).
- Rationale and trade-offs (why it changed).
- Tests or validation run (or explicit note if not run).
- Append a trailer for Codex using
Co-authored-byunless the user explicitly requests a different identity.Codex <codex@openai.com> - Wrap body lines at 72 characters.
- Create the commit message with a here-doc or temp file and use
so newlines are literal (avoid
git commit -F <file>with-m).\n - Commit only when the message matches the staged changes: if the staged diff includes unrelated files or the message describes work that isn't staged, fix the index or revise the message before committing.
- 读取会话历史记录,确定变更范围、意图和依据。
- 检查工作区和暂存的变更(通过、
git status、git diff)。git diff --staged - 在确认变更范围后,暂存目标变更,包括新文件(使用)。
git add -A - 对新增文件进行合理性检查;如果发现任何看起来随机或应该被忽略的文件(如构建产物、日志、临时文件),在提交前向用户标记该问题。
- 如果暂存不完整或包含无关文件,修正暂存区或向用户确认。
- 选择与变更匹配的规范类型和可选范围(例如、
feat(scope): ...、fix(scope): ...)。refactor(scope): ... - 以祈使语气编写主题行,长度不超过72个字符,末尾不加句号。
- 编写正文,内容包括:
- 关键变更摘要(变更了什么)。
- 变更依据和权衡考量(为什么变更)。
- 已执行的测试或验证操作(或明确说明未执行的原因)。
- 除非用户明确要求其他身份,否则添加的署名行。
Co-authored-by: Codex <codex@openai.com> - 正文每行长度不超过72个字符,自动换行。
- 通过here-doc或临时文件创建Commit Message,使用命令提交,确保换行符被正确识别(避免使用带
git commit -F <file>的\n参数)。-m - 仅当Commit Message与暂存的变更匹配时才提交:如果暂存的diff包含无关文件,或者Message描述的工作未被暂存,先修正暂存区或修改Message再提交。
Output
输出
- A single commit created with whose message reflects the session.
git commit
- 一个通过创建的Commit,其Message能反映会话上下文。
git commit
Template
模板
Type and scope are examples only; adjust to fit the repo and changes.
<type>(<scope>): <short summary>
Summary:
- <what changed>
- <what changed>
Rationale:
- <why>
- <why>
Tests:
- <command or "not run (reason)">
Co-authored-by: Codex <codex@openai.com>类型和范围仅为示例;请根据仓库和变更情况调整。
<type>(<scope>): <short summary>
Summary:
- <what changed>
- <what changed>
Rationale:
- <why>
- <why>
Tests:
- <command or "not run (reason)">
Co-authored-by: Codex <codex@openai.com>