Skip to content
Merge conflict in ...

Merge conflict in ...

DodaTech 2 min read

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 conflicts

Step 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 version

Step 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.rb

Keep the incoming branch’s version:

git checkout --theirs conflicted_file.rb

Step 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 --continue
What do the conflict markers mean?
<<<<<<< HEAD starts the current branch’s content. ======= separates the two versions. >>>>>>> branch-name marks the end of the incoming branch’s content. Everything between <<<<<<< and ======= is your version; everything between ======= and >>>>>>> is their version. Remove all markers and choose the final content.
Can I abort a merge and start over?
Yes — git merge --abort cancels the merge and restores your working directory to its state before the merge started. This is useful if the conflicts are too complex and you want to try a different strategy, like rebasing or communicating with your team first.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro