Gerrit Rebase 包括 parents

Gerrit Rebase including parents

在 gerrit 中,我通常将多个小提交放在一起。一旦它们被审查并准备好提交,我会在所有更改上看到按钮 Submit including parents,而第一个更改有一个 Submit 按钮。

在审查这些更改时,many-a-times 目标分支的 HEAD 移动到 parent 我的更改提交之前。如果我要将这整组更改重新设置到分支的当前 HEAD 上,则需要我在本地系统上手动执行并再次推送到 gerrit。我想知道我们是否有像 Rebase including parents 这样的选项,我可以在其中对整个链进行变基而无需在我的本地系统上执行任何操作(仅当它没有冲突时)?

Gerrit 2.4 version, which introduced the rebase button, as mentioned here.

rebase 只涉及一个分支,父分支中可能有祖先提交。

如果您的本地父分支在 rebase 之后发生了更改,最简单的方法是获取 Gerrit 存储库并将您的本地分支重置为新的远程分支 HEAD

git branch -f myBranch origin/myBranch
git branch -f myParentBranch origin/myParentBranch

这样,rebase 在 Gerrit 端完成,reset 在本地完成。

如果您希望目标分支的历史尽可能线性,请转到项目->常规页面并将 Submit Type 更改为 Rebase If Necessary。当您按下 SubmitSubmit including parents 时,这些提交将自动重新定位到目标分支的当前头部,而不是递归合并。请注意,为每个更改创建新的补丁集,以防您需要记录提交 sha1。并且不要忘记在必要时同步您的本地分支。

git fetch origin <target-branch>
git reset FETCH_HEAD --hard

I was wondering if we have some option like Rebase including parents where I could just rebase the whole chain without having to do anything on my local system (only if it has no conflicts)?

不,Gerrit 没有这样的功能。在 Gerrit 的 UI 中执行此操作的唯一方法是从下到上单独重新设置系列中的每个更改。

我创建了 request on the Gerrit issue tracker 以添加 "rebase including parents" 功能。