re0-git
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRewrite a finished commit message so the log hands off on its own — in the author's own voice, not an imposed one.
将已完成的提交信息重写为无需额外说明即可顺畅交接的格式——保留作者自身的表达风格,而非强加统一格式。
Goal
目标
Repeated amends and momentum commits leave a message bloated, stale, or padded with trivia. rewrites the message into a clean version that lets a fresh session continue from alone, without reading the diff. It refines what the author already writes. Only the message moves — and timestamps, per the date rule below; the tree never changes.
re0-gitgit logIt is user-invoked — run it once you've decided to commit. A commit-cleanup tool in the agent's reach would bias it toward committing when it shouldn't.
反复修改提交以及临时提交会导致提交信息臃肿、过时或充斥无关细节。可将提交信息重写为简洁版本,让后续开发者仅通过就能继续工作,无需查看diff内容。它会优化作者已撰写的内容,仅修改提交信息——以及遵循下方日期规则调整时间戳;代码树始终保持不变。
re0-gitgit log该工具需用户主动触发——在你确定要提交后再运行。若让智能代理直接使用提交清理工具,可能会导致其在不恰当的时机提交代码。
Workflow
工作流程
- Scope the target — usually , sometimes a short unpushed range.
HEAD - Read the change (,
git show --stat) and any documented commit rules. Then sample nearby non-target messages: start with 10, stop earlier if the convention is obvious, or expand only until the convention is clear.git diff - Resolve mixed logs in this order: documented project rules, nearby commits touching the same area, then same-author commits within that convention. Do not average incompatible styles or let one author's habits override the repo.
- Rewrite the message to the commit-economy (below): keep only durable handoff facts, fold supporting edits into the change they serve, and cut anything the diff or tag already proves. Give trivia no bullet of its own.
- Re-commit signed, dates per the rule below. For the tip ():
HEAD— thegit commit --amend -S --date=nowis what moves the author date to now; a bare--date=nowresets only the committer date and leaves the author date stale. For an older commit, keeping its dates: rebuild it —--amend/GIT_AUTHOR_DATE— then replay every descendant onto the rebuilt commit (a non-tip rewrite is a rebase, not a ref move), or you orphan them.GIT_COMMITTER_DATE git commit-tree <tree> -p <parent> -S -m "<new message>" - Verify and report.
- 确定目标范围——通常是,有时是一小段未推送的提交记录。
HEAD - 查看变更内容(、
git show --stat)以及任何已记录的提交规则。然后参考附近的非目标提交信息:先看10条,若风格惯例已明确可提前停止,或扩展查看直至明确惯例。git diff - 按以下优先级解决日志风格不一致问题:已记录的项目规则、同一代码区域的附近提交、该惯例下同一作者的提交。不要混合不兼容的风格,也不要让某位作者的习惯覆盖整个仓库的规则。
- 按照提交信息精简原则(见下文)重写信息:仅保留便于交接的核心事实,将辅助修改合并到对应的主变更中,删除diff或标签已能体现的内容。无关细节不要单独列项。
- 重新签名提交,日期遵循下方规则。对于最新提交():使用
HEAD——其中git commit --amend -S --date=now用于将作者日期更新为当前时间;仅使用--date=now只会重置提交者日期,作者日期仍会保持旧值。对于较早的提交,保留其原日期:使用--amend/GIT_AUTHOR_DATE重建提交——然后将所有后续提交重新基于重建后的提交(非最新提交的重写属于rebase操作,而非移动引用),或使其成为孤立提交。GIT_COMMITTER_DATE git commit-tree <tree> -p <parent> -S -m "<new message>" - 验证并反馈结果。
Rules
规则
- Never create or suggest a commit — re0-git only rewrites the message of a commit that already exists. Using it is never a reason to commit.
- Message only — the tree must stay byte-identical (empty); never edit content in a re0-git pass.
git diff <old> <new> - commit-economy — the commit-message standard this skill enforces: one bullet per real, durable change with supporting edits folded in, nothing the diff or version already proves, no co-author tags, matched to the local log's own shape (sampled above). Where that sampling finds no settled shape, fall back to a subject line, a blank line, then one bullet per change on a single unwrapped line — never prose paragraphs, which explain where a log should list. A step a documented checklist already mandates for any change of this shape (registering a new skill, syncing translated docs after a source edit) is proof the process ran, not a fact about this change — fold it as a trailing clause on the bullet it serves, or drop it if that bullet already implies it; it earns a bullet of its own only when something about how it was done is itself non-obvious. The same bar governs the first draft; re0-git only enforces it on a message that already drifted past it.
- - Dates by position; always gpg-signed. The commit you're finalizing — — takes both author and committer date = now, because re-cleaning the latest commit is itself continued work. Every older commit (
HEADand back) keeps its original author + committer dates; never restamp the past.HEAD~1 - Never rewrite pushed or shared history without explicit confirmation — it forces a force-push.
- 绝不创建或建议提交——仅重写已存在的提交信息,使用该工具绝不能成为提交代码的理由。
re0-git - 仅修改提交信息——代码树必须完全一致(输出为空);在
git diff <old> <new>操作中绝不能修改代码内容。re0-git - 提交信息精简原则——该工具遵循的提交信息标准:每个真实、持久的变更对应一个列表项,辅助修改合并到对应主变更中,不包含diff或版本已能体现的内容,不添加协作者标签,匹配本地日志的格式(参考上文的采样)。若采样未发现统一格式,则退化为:主题行、空行、每个变更用一个开头的列表项,且每行不换行——绝不使用散文段落,日志应列出变更而非解释。若某步骤是此类变更的既定检查清单要求(例如注册新技能、源文件编辑后同步翻译文档),仅能证明流程已执行,不属于本次变更的核心信息——可将其作为对应列表项的末尾从句,或若该列表项已隐含此步骤则直接删除;只有当该步骤的执行方式本身不明显时,才单独列为一个列表项。初稿也需遵循此标准,
-仅对偏离该标准的提交信息进行修正。re0-git - 日期按位置确定;始终使用GPG签名。你正在定稿的提交————的作者日期和提交者日期均设为当前时间,因为重新整理最新提交本身属于后续工作。所有较早的提交(
HEAD及之前)保留其原作者日期和提交者日期;绝不能修改过往提交的时间戳。HEAD~1 - 未经明确确认,绝不重写已推送或共享的提交历史——这会强制要求执行强制推送。
Verification
验证步骤
- is empty — content unchanged.
git diff <old-tip> <new-tip> - Each rewritten commit is gpg-signed (=
%G?) with dates as intended.G - Re-read alone, diff hidden — if any cut line turns out to be needed to follow the change, restore it.
git log
- 输出为空——代码内容未改变。
git diff <old-tip> <new-tip> - 每个重写后的提交均已GPG签名(输出为
%G?),日期符合预期。G - 仅查看,隐藏diff内容——若发现被删除的内容对理解变更有必要,则恢复该内容。
git log