Errorgit

Automatic merge failed; fix conflicts

What Automatic merge failed actually means, how to read git's conflict markers, and the safe steps to resolve, commit, or abort the merge.

Last updated

Errorgit
Auto-merging src/app.js
CONFLICT (content): Merge conflict in src/app.js
Automatic merge failed; fix conflicts and then commit the result.

What it means: Git merged everything it safely could and found lines in the same file changed differently on both branches, so it's leaving the decision to you instead of guessing.

Likely causes

Most probable first — with how to confirm.

  • 1.Two branches edited the same lines of the same file for different reasons, a common overlap during parallel feature work — open the file and look for the `<<<<<<<` / `=======` / `>>>>>>>` markers git inserted.
  • 2.One branch deleted a file or block that the other branch modified — git flags this as a conflict too, not just line-level text clashes.
  • 3.You're merging a long-diverged branch (rebased history vs. the original), so git sees the same logical change expressed as two different diffs.

Fixes

Safest first; destructive ones are called out.

  • Open each conflicted file, resolve the markers by choosing or combining the right content, delete the `<<<<<<<` / `=======` / `>>>>>>>` lines, then `git add <file>` and `git commit` to finish the merge.
  • Run `git status` to see the full list of conflicted files — don't assume it's only the one file git printed first.
  • For a conflict where one side should win entirely, `git checkout --ours <file>` or `--theirs <file>` picks that side wholesale — verify that's actually intended first, since it discards the other side's changes to that file.
  • If the merge is a mess, `git merge --abort` cleanly returns you to the pre-merge state — but only before you commit the resolution.

Related in Errors