commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

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
    ,
    git diff
    , and
    git diff --staged
    for actual changes.
  • Repo-specific commit conventions if documented.
  • 用于了解意图和依据的Codex会话历史记录。
  • 用于查看实际变更的
    git status
    git diff
    git diff --staged
    输出。
  • 仓库文档中规定的特定Commit规范(如有)。

Steps

步骤

  1. Read session history to identify scope, intent, and rationale.
  2. Inspect the working tree and staged changes (
    git status
    ,
    git diff
    ,
    git diff --staged
    ).
  3. Stage intended changes, including new files (
    git add -A
    ) after confirming scope.
  4. Sanity-check newly added files; if anything looks random or likely ignored (build artifacts, logs, temp files), flag it to the user before committing.
  5. If staging is incomplete or includes unrelated files, fix the index or ask for confirmation.
  6. Choose a conventional type and optional scope that match the change (e.g.,
    feat(scope): ...
    ,
    fix(scope): ...
    ,
    refactor(scope): ...
    ).
  7. Write a subject line in imperative mood, <= 72 characters, no trailing period.
  8. 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).
  9. Append a
    Co-authored-by
    trailer for Codex using
    Codex <codex@openai.com>
    unless the user explicitly requests a different identity.
  10. Wrap body lines at 72 characters.
  11. Create the commit message with a here-doc or temp file and use
    git commit -F <file>
    so newlines are literal (avoid
    -m
    with
    \n
    ).
  12. 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.
  1. 读取会话历史记录,确定变更范围、意图和依据。
  2. 检查工作区和暂存的变更(通过
    git status
    git diff
    git diff --staged
    )。
  3. 在确认变更范围后,暂存目标变更,包括新文件(使用
    git add -A
    )。
  4. 对新增文件进行合理性检查;如果发现任何看起来随机或应该被忽略的文件(如构建产物、日志、临时文件),在提交前向用户标记该问题。
  5. 如果暂存不完整或包含无关文件,修正暂存区或向用户确认。
  6. 选择与变更匹配的规范类型和可选范围(例如
    feat(scope): ...
    fix(scope): ...
    refactor(scope): ...
    )。
  7. 以祈使语气编写主题行,长度不超过72个字符,末尾不加句号。
  8. 编写正文,内容包括:
    • 关键变更摘要(变更了什么)。
    • 变更依据和权衡考量(为什么变更)。
    • 已执行的测试或验证操作(或明确说明未执行的原因)。
  9. 除非用户明确要求其他身份,否则添加
    Co-authored-by: Codex <codex@openai.com>
    的署名行。
  10. 正文每行长度不超过72个字符,自动换行。
  11. 通过here-doc或临时文件创建Commit Message,使用
    git commit -F <file>
    命令提交,确保换行符被正确识别(避免使用带
    \n
    -m
    参数)。
  12. 仅当Commit Message与暂存的变更匹配时才提交:如果暂存的diff包含无关文件,或者Message描述的工作未被暂存,先修正暂存区或修改Message再提交。

Output

输出

  • A single commit created with
    git commit
    whose message reflects the session.
  • 一个通过
    git commit
    创建的Commit,其Message能反映会话上下文。

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>