Back to Errors

Merge conflict

What is this error?

Two versions changed the same lines and Git refuses to guess which one is correct. It has marked both inside the file and is waiting for you.

Common Causes

  • The same lines were edited in two places.
  • A long-lived branch drifted far from main.

How to fix it (Check First)

  • 1Run `git status` to list conflicted files.
  • 2Open each file and find the <<<<<<< / ======= / >>>>>>> markers.
  • 3Keep the correct result, delete all markers, then `git add` the file and commit.

What NOT to do

  • Do not delete the whole file to make the markers go away.

Technical Details

Conflict markers delimit ours/theirs hunks. `git checkout --ours/--theirs <file>` selects a side wholesale; `git merge --abort` returns to the pre-merge state.