Resolving merge conflicts

From OSM Public Wiki
Revision as of 02:31, 20 February 2017 by Benalaya (talk | contribs) (Created page with " To resolve problem of merge conflicts, in some cases it is enough to do a simple rebase using the Gerrit interface. However, in other cases some choices and updates need be d...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To resolve problem of merge conflicts, in some cases it is enough to do a simple rebase using the Gerrit interface. However, in other cases some choices and updates need be done to resolve the conflicts using your editor that cannot be done using the Gerrit UI.

These are the steps to follow to resolve the conflict and update the commit on Gerrit so it can be merged.

1. Get the last code from the repository

  • git checkout master
  • git pull origin master


2. Create a new branch to work on the code with conflicts. You can use the review number and patchset as name.

  • git checkout -b <review-number>-<patchset>


3. Pull the patch on the created branch. (To find the command to execute you can open the corresponding change page on Gerrit UI, click on download menu, then copy the "pull" command.)

  • git pull <url> <ref>


Note: The two previous steps could be simplified using git-review tool. The following command takes as input the review number, it creates a local branch and pull the change on it automatically.

  • git review -d <review-number>


4. Make a rebase of your branch against master

  • git rebase master


5. Fix all conflicts that cannot be resolved manually using your editor.

6. Add all updated files to the index.

  1. git add <file>

Note: You can use git-status to make sure that conflicts are solved

  • git status


7. Continue the rebase process using the following command

  • git rebase --continue


8. Submit your change back to the repository

  • git push origin HEAD:refs/for/master


Note: If you are using git-review tool, the previous step could be done with the following command

  • git review


9. Go back to Gerrit UI. You will find the change waiting for review.