git 从 Gerrit 中删除补丁

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11369983/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:10:48  来源:igfitidea点击:

Removing patch from Gerrit

gitgerrit

提问by endmade

I submitted a patch for review to Gerrit, which created a review page. I wanted to update the patch with some modifications, but unfortunately ended up submitting a new patch, which depended on the old one, along with a new corresponding review page. This happened because I did not amend to the previous commit, rather I made a new commit and pushed that for review.

我向 Gerrit 提交了一个补丁以供,后者创建了一个页面。我想通过一些修改来更新补丁,但不幸的是最终提交了一个新补丁,该补丁依赖于旧补丁,以及一个新的相应评论页面。发生这种情况是因为我没有修改之前的提交,而是我进行了新的提交并将其推送以供。

What I'm wondering now is if there is a way revert the most recent commit, amend changes to the older commit and have that be reflected on Gerrit, thus removing the most recent review page and update the old one.

我现在想知道是否有办法恢复最近的提交,修改对旧提交的更改并将其反映在 Gerrit 上,从而删除最近的评论页面并更新旧的。

Feel free to edit my question, or ask me if I'm not being clear.

随意编辑我的问题,或者问我是否不清楚。

回答by Brad

Sure this is possible. There are 2 tasks - Clean up your Git repository and update Gerrit.

当然这是可能的。有 2 个任务 - 清理您的 Git 存储库并更新 Gerrit。

To clean up git, there are a couple approaches. The most automatic method is to squash your 2 current commits together using git rebase -i. Another option is to do something like git checkout HEAD^ && <make edits> && git commit --amend.

要清理 git,有几种方法。最自动化的方法是使用git rebase -i. 另一种选择是做类似的事情git checkout HEAD^ && <make edits> && git commit --amend

Once you are happy with your git tree, push up to Gerrit creating a new patch set for your original change. Then use the 'Abandon' button on the change you made accidentally and you should be good to go.

一旦您对您的 git 树感到满意,请向上推送 Gerrit,为您的原始更改创建一个新的补丁集。然后在您不小心所做的更改上使用“放弃”按钮,您应该很高兴。