commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCommit
Commit
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字符,末尾不加句号。
- 编写正文,包含以下内容:
- 关键变更摘要(改了什么)。
- 变更理由和权衡(为什么改)。
- 已执行的测试或验证(如果未执行要明确注明)。
- 追加尾部信息,标注Codex为共同作者,内容为
Co-authored-by,除非用户明确要求使用其他身份。Codex <codex@openai.com> - 正文每行长度限制在72字符,超出自动换行。
- 使用here-doc或者临时文件生成commit信息,使用提交以保留换行符(避免使用带
git commit -F <file>的\n参数)。-m - 仅当commit信息和暂存变更匹配时才执行提交:如果暂存diff包含无关文件,或者信息描述的内容未被暂存,先修正暂存区或者修改提交信息再提交。
Output
输出
- A single commit created with whose message reflects the session.
git commit
- 通过创建的单个commit,其提交信息与会话内容匹配。
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>