Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot merge in Gerrit

Tags:

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

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

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 merge from current review. Thanks!

like image 698
Bhargav Kumar R Avatar asked Jun 02 '16 05:06

Bhargav Kumar R


People also ask

How do I fix merge conflict Gerrit?

In some cases, it is possible to resolve merge conflicts issues in Gerrit using simple rebase triggered directly from the Gerrit UI. Just click on "Rebase" button to rebase the change. The behaviour is described in Gerrit Review UI: If the rebase is successful, a new patch set with the rebased commit is created.

How do I merge in Gerrit?

To do that, you click the “Submit” button in the Gerrit Web UI just as you would click the “Merge Pull Request” button in GitHub. Both, Gerrit and GitHub, allow different merge strategies, that can be enabled by project administrators.

What is rebase in Gerrit?

Rebasing. Rebasing is usually the last step before pushing changes to Gerrit; this allows you to make the necessary Change-Ids. The Change-Ids must be kept the same. squash: mixes two or more commits into a single one. reword: changes the commit message.

What is git merge tool?

Use git mergetool to run one of several merge utilities to resolve merge conflicts. It is typically run after git merge. If one or more <file> parameters are given, the merge tool program will be run to resolve differences on each file (skipping those without conflicts).


2 Answers

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

  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)
like image 66
Marcelo Ávila de Oliveira Avatar answered Oct 24 '22 15:10

Marcelo Ávila de Oliveira


Try rebase button, 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.

like image 22
ElpieKay Avatar answered Oct 24 '22 15:10

ElpieKay