Home › Git

CONFLICT (content): Merge conflict in — how to fix

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

Quick fix: Open the file, pick the right code between <<<<<<<, ======= and >>>>>>>, delete the markers, then git add <file> and git commit (or git rebase --continue). Changed your mind: git merge --abort.

What it means

Git merged everything it could, but in at least one file both sides changed the same lines differently. It needs you to decide.

See which files conflict

git status       # listed under "Unmerged paths"

Resolve a file

Inside the file you'll see:

<<<<<<< HEAD
const port = 3000;
=======
const port = process.env.PORT || 8080;
>>>>>>> feature-branch

Edit it to the final version you want and delete all three marker lines:

const port = process.env.PORT || 3000;

Then mark it resolved and finish:

git add src/app.js
git commit                 # for a merge
git rebase --continue      # if you were rebasing
git cherry-pick --continue # if you were cherry-picking

Take one side for a whole file

git checkout --ours   src/app.js    # keep your version
git checkout --theirs src/app.js    # take the incoming version
git add src/app.js

During a rebase, "ours" and "theirs" are swapped: --ours is the branch you're rebasing onto.

Give up and go back

git merge --abort     # or: git rebase --abort

Tools that help

Lock files

For package-lock.json, yarn.lock or poetry.lock, don't hand-edit. Take either version and regenerate: git checkout --theirs package-lock.json && npm install, then git add it.

Last updated 2026-10-27.