How to Resolve a Git Merge Conflict

Git stopped mid-merge with 'CONFLICT' and strange <<<<<<< markers in your files. It's not broken — Git is asking you to choose. Here's how to read the markers and finish the merge calmly.

BytExplorer 6 min read July 1, 2026

You merge (or pull, or rebase) and Git stops:

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

A conflict just means two branches changed the same lines, and Git can't safely guess which version wins. It hasn't lost anything — it's handing the decision to you. Nothing is broken.

Step 1: See what conflicted

git status      # lists files under "Unmerged paths"

Only the files listed there need your attention. Everything else merged fine.

Step 2: Read the conflict markers

Open a conflicted file and you'll see a block like this:

<<<<<<< HEAD
price = 9.99        # your version (the branch you're on)
=======
price = 12.99       # the incoming version (the branch being merged in)
>>>>>>> feature/pricing
  • Above ======= is your current branch (HEAD).
  • Below it is the incoming change.
  • The <<<<<<<, =======, >>>>>>> lines are just delimiters.

Step 3: Choose the correct result

Edit the file so it contains the code you actually want — which might be one side, the other, or a blend of both. Then delete all three marker lines. The file should read as clean, normal code with no <<<<<<< left anywhere.

price = 12.99

Step 4: Mark it resolved and finish

git add app.py         # tells Git this file's conflict is settled
git status             # confirm no files remain unmerged
git commit             # completes the merge (message is pre-filled)

The single most common mistake is committing with a marker line still in the file. Before you git add, search the project for <<<<<<< — if it turns up, you're not done yet.

If you want to bail out

Changed your mind mid-merge? Abort and return to before the merge started:

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

The checklist

  1. git status — find the unmerged files.
  2. Open each, read the <<<<<<< / ======= / >>>>>>> blocks.
  3. Edit to the version you want; delete every marker line.
  4. git add each file, then git commit.
  5. Grep for <<<<<<< before committing — no markers should remain.

Frequently Asked Questions

How do I see which files have a merge conflict? Run git status — conflicted files are listed under "Unmerged paths". To jump straight to them, search the project for the markers with git grep "<<<<<<<". Only the files listed there need editing.

How do I cancel or abort a merge conflict? If you started a merge, git merge --abort returns you to exactly where you were before it began. Mid-rebase, use git rebase --abort instead. Nothing you had already committed is lost.

What does "needs merge" or "you need to resolve your current index first" mean? Git is telling you a file still has an unresolved conflict. Finish editing it, remove the <<<<<<< / ======= / >>>>>>> markers, git add it, and the "needs merge" state clears.

Can I just keep my version or just theirs? Yes. To take your current branch's version of a file wholesale: git checkout --ours path/to/file. For the incoming version: git checkout --theirs path/to/file. Then git add the file to mark it resolved.

How do I know the conflict is fully resolved? git status should show no files under "Unmerged paths", and a search for <<<<<<< should return nothing. Then git commit completes the merge.

Put it into practice

Stop reading, start building

This pairs with a hands-on BytExplorer course — do it on your own machine and actually keep the skill.

More in Troubleshooting