Skip to content

Resolve conflicts with the main branch

When someone changed the same lines on the main branch as you did, choose which version to keep, or combine them by hand.

Each time you open a page, and after every save, the editor merges the latest main branch into your working branch. It never rewrites your commits. Changes to different files, or to different parts of one file, merge on their own. When the same lines changed on both sides, the editor shows The main branch has changes that conflict with yours, and you cannot publish until you resolve them.

On a repository that requires signed commits, GitHub does the merging instead, through your pull request; see Verified commits.

  1. Choose Resolve the conflicts.

    Each file in conflict shows Your version and the Current version on the main branch side by side.

  2. For each file, choose one.
    • Keep your version.
    • Keep the current version, dropping your change to that file.
    • Edit by hand, then combine the two in the box below.

    The hand-edit box starts with both versions between marker lines (<<<<<<<, =======, >>>>>>>). Keep the text you want and delete the marker lines. A version with markers left in, or that is not well-formed XML, is refused; see Validation diagnostics.

  3. Choose Save my choices.

    Your choices are saved to your branch as a merge commit. Nothing is published.

    If your branch or the main branch changed while you were choosing, the editor refuses the save and asks you to review the files again.

Some conflicts cannot be resolved by choosing a version:

  • you deleted a file that was changed on the main branch, or it was deleted there after you changed it;
  • a file that is not text, such as an image, changed on both sides;
  • sections you edited (elements with an id) were deleted on the main branch.

The page then says A developer needs to resolve this. Choose Ask a developer: the editor opens or updates your pull request with a note naming the files, and a developer resolves them there.