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.
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
git status— find the unmerged files.- Open each, read the
<<<<<<< / ======= / >>>>>>>blocks. - Edit to the version you want; delete every marker line.
git addeach file, thengit commit.- Grep for
<<<<<<<before committing — no markers should remain.
Stop reading, start building
This pairs with a hands-on BytExplorer course — do it on your own machine and actually keep the skill.