Merge Conflict
Quick summary
Git stopped mid-merge because both branches edited the same lines — you must manually choose which version to keep.
Why this happens
Both branches modified the same lines of the same file
One branch deleted a file while the other modified it
Conflicting changes were made to overlapping regions
Minimal example
<<<<<<< HEAD
const port = 3000;
=======
const port = 8080;
>>>>>>> feature-branchconst port = 8080; // resolved: use the feature branch's valueBoth branches set port to different values — choose the correct one (8080), remove the conflict markers, and commit.
How to diagnose
Run
git statusto see which files have conflictsOpen the conflicted files and look for
<<<<<<<,=======, and>>>>>>>markersReview both versions to understand what each branch changed
How to fix
Edit each conflicted file to keep the correct version and remove the markers
Run
git add <file>to mark the conflict as resolvedRun
git commit(orgit merge --continue) to complete the merge
How to prevent
Pull from the remote frequently to keep your branch up to date
Keep feature branches short and merge them quickly
Communicate with your team to avoid editing the same files simultaneously
Related Resources
Related Lessons
- What is Git?
Learn Git fundamentals including merging
Related Practice
- Understanding Git Commits
Understand Git commits and merging.