如何使 Gerrit 提交历史与 git 日志保持一致?

How to keep Gerrit commit history same with git log?

我已经 git 成功替换并推送到我的回购历史记录。

但 Gerrit 仍然保留了整个历史。

例如

替换前:git 和 gerrit

中都有 commit 1, 2 ,3

替换后:我在 git 中做了 仅提交 1,而 git 克隆仅显示提交 1,这就是我想要的

但是仍然在 gerrit 中提交 1,2,3。

这没有意义...为什么?以及如何清理 gerrit 历史记录以保持 与 git 日志相同

这是我的命令
$ git clone ssh://myrepo.git
$ HP=xxxx #get a commit Hash value as a history point
$ git branch history $HP
$ echo 'new starts here' | git commit-tree $HP^{tree} # return value as new base $NB
$ git rebase --onto $NB $HP
$ git push origin master -f

感谢任何帮助。

我认为您将 Gerrit 更改与 Git 提交混淆了。当您使用“git push origin master -f”时,您强制将新的提交历史直接推送到绕过 Gerrit 的 Git 分支(master)。

由于先前存在的提交而生成的 Gerrit 更改将继续存在。遗憾的是,Gerrit 更改合并后无法删除(只能删除打开或放弃的更改)。另一方面,这些更改不会对实际的 Git 存储库产生任何副作用,这显然应该如您所料。