Founding prices until 15 December: 30% off Pro, locked for life. See pricing

$ … CONFLICT (content): Merge conflict in ... Automatic merge failed

Git merge conflict: how to resolve it calmly

Both branches changed the same lines, and Git needs you to choose.

Git

What it means

Git merged everything it could and stopped at the lines both sides changed. It marks them with <<<<<<<, ======= and >>>>>>> in the files. Nothing is lost: you edit, mark resolved, and continue.

Causes and fixes

Most likely first. Run the check, and if it matches, apply the fix.

1. The same lines were changed on both branches

Check:

git status
git diff --name-only --diff-filter=U

Fix: Edit each file to the correct result, remove the markers, git add the files, then git commit (or git rebase --continue).

2. One side is clearly right for a whole file (generated files, lock files)

Check:

git diff <file>

Fix: git checkout --ours <file> or --theirs <file> (careful, they swap meaning during a rebase), then git add.

3. You want to start over

Check:

git status

Fix: git merge --abort (or git rebase --abort) returns to before the merge.

Fix it yourself

A live machine in your browser with this problem already on it. The grader checks the result.

Open the lab

No account needed for your first tries.

Related errors