Merge conflict

Git OperationsMerge ErrorCommonLast updated: June 29, 2026Tested on:Git CLI v2.44GitHub APIJune 2026

This error occurs when you merge two branches that have conflicting changes on the same lines of the same file, forcing manual resolution.

Merge conflict Quick Fix⏱️ Est. Fix Time: 4 minutes

Usually happens because:

  • Simultaneous edits on the same lines of code on two different branches
  • File deleted on one branch and edited on another branch
  • Line endings formatting mismatch modifying code blocks

🔍 Quick Checklist:

What is Merge conflict?

A merge conflict happens when Git cannot automatically reconcile differences between two commits. During a merge, rebase, or pull operation, if the same lines of a file have been changed differently in both branches, Git pauses the operation, inserts special conflict markers (<<<<<<<, =======, >>>>>>>) into the affected files, and requires you to manually resolve the differences before concluding the merge commit.

Common Causes

  • Concurrent changes on the same line: Two developers changed the exact same line of a file in different ways.
  • File deleted in one branch but modified in another: One branch deleted a file while another branch made edits to it.
  • Divergent line endings: Cross-platform differences (LF vs CRLF) modifying entire file formats, making Git perceive them as completely conflicting.
CauseFrequency
Simultaneous changes on the same lines of code⭐⭐⭐⭐⭐
File deleted on one branch and edited on another⭐⭐⭐
Line endings formatting conflicts (LF vs CRLF)⭐⭐

Common Mistakes

  • Accidentally committing files with the raw Git conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`) still written inside the code, leading to syntax compilation crashes.
  • Forgetting to run `git commit` after adding (`git add`) the resolved conflict files.

How to Fix

1Identify and edit conflict markers: Open conflicting files, locate the conflict markers, and choose which changes to keep.
2Mark resolved and commit: Add resolved files using 'git add' and run 'git commit' to complete the merge.
3Abort the merge: If needed, stop the operation and revert back to your original branch state using 'git merge --abort'.

Git Operations & Verification

Conflict markers inserted by Git to show conflicting blocks in index.js.

Inside Conflict File Example
<<<<<<< HEAD
const port = 3000; // Your change on main branch
=======
const port = 8080; // Incoming change from feature branch
>>>>>>> feature-branch

Platform Specific Fixes

Use command-line merge tools like Meld or Vimdiff to resolve conflicts graphically.

Linux Config
# Set default merge tool
git config --global merge.tool vimdiff
# Open conflict resolution interface
git mergetool

Best Practices

  • Pull the destination branch (`main`) into your working branch frequently to resolve small conflicts early.
  • Avoid making large formatting edits (like re-indenting entire files) in shared codebase files.

Frequently Asked Questions (FAQ)

Q: What are conflict markers?

Git inserts <<<<<<< to mark the beginning of your changes (HEAD), ======= as the separator, and >>>>>>> to mark the end of incoming changes from the merged branch.

Q: How do I undo a merge conflict state?

You can safely abort the merge process and restore your previous branch state by running 'git merge --abort'.

Q: How do I resolve conflicts using a specific tool?

Configure a merge tool using 'git config --global merge.tool <tool-name>' and run 'git mergetool'.

Q: Why did a pull command trigger conflicts?

'git pull' runs 'git fetch' followed by 'git merge' under the hood. If your local changes clash with remote commits, the merge phase will trigger conflicts.

Still having this problem?

Didn't solve your problem?

SuggestRequest Error