今日英语表达 12/30 · 阶段:PR 说明。 例句均为本文专门编写。并非引用实际仓库的 PR,分支和编号仅为示例。
目录
一目了然
| 表达 | Rebased onto main (to resolve conflicts). |
| 含义 | 已将分支变基到 main 的最新提交之上(以解决冲突)。 |
| 使用场景 | PR 评论、评审回复、评审者的要求 |
| 礼貌程度 | 中立。属于工作汇报。 |
1. 含义与语境
rebase 直接借用了 Git 命令作为动词。这是一项将我方分支的提交拆下来、 重新堆叠到另一个提交之上 的操作。因此,介词使用的是意为“在……之上”的 onto 。rease onto main 意为“重新堆叠到 main 的末尾之上”。日常中也会用到 rebase on main,但正如 Git 文档也使用了 --onto 这样的选项名称一样,onto 能够提供更准确的画面感。
评审者之所以想了解这一点,是因为 rebase 会 改变提交哈希(commit hash) 。若要推送 rebase 后的分支,必须进行强制推送(force push),而在 GitHub 的 PR 界面上,之前看到的提交会仿佛消失了一般。因此,留下一句“代码内容保持不变,仅更新了基础分支”可以节省评审者的宝贵时间。
我们也要了解它与 merge 的区别。merge main into my branch 会创建一个将 main 合并到当前分支的合并提交(merge commit)。而 rebase 不会产生合并提交,它能将提交历史保持在一条直线上。每个仓库倾向的选择各有不同。CloudNativePG 的贡献文档中说明,GitHub 已被设置为没有合并提交的线性开发(linear development)模式。在此类仓库中,rebase 是默认操作。
进行强制推送时, git push --force-with-lease 养成使用这一习惯会很好。如果远程分支的状态与你最后看到的不一致,系统会拒绝推送,这样就能避免维护者意外删除你在其分支上添加的提交。
2. 例句
场景 1:解决冲突后
Rebased onto main to resolve the conflict in
go.mod. No other changes.
加上 No other changes 后,评审者就会明白无需再重新检查其他内容。
场景 2:当评审者提出要求时
Could you rebase onto the latest main? #3300 changed the same function and CI is failing on this branch.
场景 3:当 rebase 与代码修改交织在一起时
Rebased onto main and addressed the review comments. The only new change is in
validate.go; everything else is from the rebase.
如果将因 rebase 改变的部分与自己直接修复的部分区分开来告知对方,评审者就只会关注需要重新审阅的地方。
3. 相似表达与区别
- Merged main into this branch. 意为创建了合并提交。在要求线性历史的仓库中,你可能会收到重新进行 rebase 的请求。
- Force-pushed. 汇报已经进行了强制推送。有时也会像 Sorry for the force-push 这样,提前为评审过程中的强制推送致歉。
- Synced with upstream. 这是一个较广义的表述,表示已将 fork 仓库与上游仓库同步。并未指明使用的是 rebase 还是 merge。
4. 韩国人常犯的错误
- I updated the branch to latest. 无法得知是哪个仓库的最新状态,也分不清是 rebase 还是 merge。
- 修改后的句子:Rebased onto the latest main.
- I did rebase. 不用加 do,rease 本身就可以作为动词使用。
- 修改后的句子:I've rebased the branch.
- Rebased to main. 虽说算不上完全错误,但 onto 能够更准确地描绘出这一动作。
- 修改后的句子:Rebased onto main.
5. 一行练习
请将以下韩语句子改写为 PR 评论。
已变基到 main 最新版本并解决了冲突。没有代码更改。
参考答案
Rebased onto the latest main to resolve conflicts. No code changes.
conflicts 用于概括多个文件的冲突,因此使用复数形式。如果只有一个,则使用 the conflict。
Titi 小贴士。 记得用一句话告知提交哈希值已发生更改。这样评审者就无需从头重新阅读。
参考资料
- Git 문서, git-rebase: https://git-scm.com/docs/git-rebase
- Git 문서, git-push(
--force-with-lease): https://git-scm.com/docs/git-push - CloudNativePG, Contributing to the source code: https://github.com/cloudnative-pg/cloudnative-pg/blob/main/contribute/README.md