Merge conflict in ...
Git’s Merge conflict in <file> means two branches changed the same part of a file, and Git can’t decide which version to keep — you must resolve it manually.
What It Means
When you run git merge, Git tries to combine changes from two branches. If both branches modified the same lines in different ways, or if one branch deleted a file while the other modified it, Git can’t auto-merge. It pauses the merge and marks the conflicted files with special markers (<<<<<<<, =======, >>>>>>>) showing both versions. Git won’t complete the merge until every conflict is resolved.
Why It Happens
- Two developers edited the same lines in the same file on different branches.
- A file was deleted on one branch but modified on another.
- One branch modified a file’s permissions while the other changed its content.
- A cherry-pick applies changes that conflict with existing modifications.
- A rebase replays commits onto a different base and encounters overlapping changes.
How to Fix It
Step 1: Identify conflicted files
git status
# Files under "Unmerged paths" have conflictsStep 2: Open the conflicted file
You’ll see conflict markers:
<<<<<<< HEAD
This is the current branch's version
=======
This is the incoming branch's version
>>>>>>> feature-branch<<<<<<< HEAD— your current branch’s version=======— separates the two versions>>>>>>> feature-branch— the incoming branch’s version
Step 3: Resolve the conflict manually
Edit the file to keep what you want and remove the markers:
This is the final resolved versionStep 4: Use git mergetool (optional)
git mergetool
# Opens your configured diff tool (vimdiff, VS Code, meld, etc.)Step 5: Accept one side entirely (if appropriate)
Keep the current branch’s version:
git checkout --ours conflicted_file.rbKeep the incoming branch’s version:
git checkout --theirs conflicted_file.rbStep 6: Mark as resolved and commit
git add conflicted_file.rb
git commit -m "Resolve merge conflict in conflicted_file.rb"
# Or continue a merge in progress:
git merge --continueBuilt by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro