Cannot merge in Gerrit

Bhargav Kumar R picture Bhargav Kumar R · Jun 2, 2016 · Viewed 33.9k times · Source

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!

Answer

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)