git 无法在 Gerrit 中合并

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37583710/
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-09 04:14:07  来源:igfitidea点击:

Cannot merge in Gerrit

gitgit-mergegerrit

提问by Bhargav Kumar R

Whenever I sent a review to Gerrit and if the review is pending for some time, I am getting cannot mergemessage in Gerrit.

每当我向 Gerrit 发送评论时,如果评论等待一段时间,我就会收到cannot mergeGerrit 中的消息。

I understood its coming because somebody else would have changed same file/files and delivered before me. I am trying below workaround to solve my issue.

我理解它的到来,因为其他人会更改相同的文件/文件并在我之前交付。我正在尝试以下解决方法来解决我的问题。

  1. Abandon the current review.
  2. Create a new local branch, take a pull
  3. Cherry-pick my commit from old branch and send to gerrit
  1. 放弃当前的。
  2. 创建一个新的本地分支,拉取
  3. 从旧分支樱桃挑选我的提交并发送到 gerrit

This works but the review comments whatever I had would no longer be available and it is difficult for my reviewer to check it again.

这有效,但我所拥有的评论评论将不再可用,我的评论者很难再次检查它。

I am looking for a way to remove cannot mergefrom current review. Thanks!

我正在寻找一种cannot merge从当前评论中删除的方法。谢谢!

回答by Marcelo ávila de Oliveira

You do NOT need to abandon the current change on Gerrit to solve the "cannot merge" issue. All you need to do is:

您不需要放弃 Gerrit 上的当前更改来解决“无法合并”问题。您需要做的就是:

  1. Update your local repository (git fetch)
  2. Run a manual rebase (git rebase)
  3. Resolve the conflicts (git mergetool, git rebase --continue)
  4. Commit (amend) the result (git commit --amend)
  5. Push a new patchset to Gerrit (git push)
  1. 更新您的本地存储库 (git fetch)
  2. 运行手动变基 (git rebase)
  3. 解决冲突(git mergetool、git rebase --continue)
  4. 提交(修改)结果(git commit --amend)
  5. 将新补丁集推送到 Gerrit (git push)

回答by ElpieKay

Try rebasebutton, which can solve most cannot-merge issues. If it can find the proper commit to rebase onto by itself, it's okay. If it cannot, find the last commit of the target branch and fill in the commit blank. Sometimes you should first submit the commit, on which the cannot-merge one has dependency. If it cannot work anyhow, just abandon it and make the commit based on the latest commit.

尝试rebase按钮,可以解决大部分无法合并的问题。如果它可以找到合适的提交来自己变基,那就没问题了。如果不能,则找到目标分支的最后一次提交,并填写提交空白。有时您应该首先提交提交,无法合并的提交依赖于该提交。如果无论如何它都无法工作,只需放弃它并根据最新提交进行提交。

回答by Timotei

The best practice when working on a shared code base using git/gerrit is to keep individual changes as small as possible. Instead of submitting your change in a single larger commit, split it into a series of smaller commits (submit the branch to gerrit) that have one logical change per commit. This workflow:

使用 git/gerrit 处理共享代码库时的最佳实践是使单个更改尽可能小。不要在单个较大的提交中提交更改,而是将其拆分为一系列较小的提交(将分支提交给 gerrit),每个提交具有一个逻辑更改。此工作流程:

  • reduces the chance of conflict in a single change
  • makes conflicts easier and quicker to resolve
  • make the change quicker to review
  • 减少单个更改中发生冲突的机会
  • 使冲突更容易、更快速地解决
  • 使更改更快地

This way, the chance that someone merges his changes before you lowers. You should rebase as soon as possibleso that the changes can be reviewed more easily. Rebasing regularly against the upstream branch means you keep up-to-date with changes, and don't have to deal with a large merge conflict (you get smaller, more manageable issues to resolve).

这样,有人在您降低之前合并他的更改的机会。您应该尽快变基,以便可以更轻松地查看更改。定期针对上游分支进行重新定位意味着您可以随时了解更改,并且不必处理大型合并冲突(您需要解决更小、更易于管理的问题)。

I'm not sure this answers your question but I follow these two rules and have no problems.

我不确定这是否能回答您的问题,但我遵循这两条规则并且没有任何问题。