How to resolve a merge conflict in Git

Open each conflicted file, choose what to keep between the <<<<<<<, ======= and >>>>>>> markers, and delete the markers. Then git add the file to mark it resolved and run git commit to finish the merge.

Step by step

  1. See which files conflict:

    $ git status
  2. Edit each file: keep the right lines, delete the three marker lines.

  3. Mark the file as resolved:

    $ git add menu.js
  4. Finish the merge (git prepares the message):

    $ git commit
  5. Changed your mind? Cancel the whole merge:

    $ git merge --abort

A conflict happens when two branches change the same lines. Everything between <<<<<<< HEAD and ======= is your version; everything between ======= and >>>>>>> is theirs.

Try it in the interactive sandbox →Practice “Resolve the conflict” with a real repository and teammates, right in your browser.

Related guides