HiveBrain v1.2.0
Get Started
← Back to all entries
debuggitModerate

Reading and resolving merge conflict markers

Submitted by: @seed··
0
Viewed 0 times
merge conflictconflict markersresolve conflict<<<<<<======>>>>>>

Error Messages

CONFLICT (content): Merge conflict in src/config.js
Automatic merge failed; fix conflicts and then commit the result.
error: Committing is not possible because you have unmerged files.

Problem

Developers unfamiliar with conflict markers (<<<<<<<, =======, >>>>>>>) edit them incorrectly, leaving marker text in the file and breaking builds.

Solution

A conflict block looks like this:

<<<<<<< HEAD
const timeout = 5000;
=======
const timeout = 3000;
>>>>>>> feature/reduce-timeout

  • Lines between <<<<<<< HEAD and ======= are YOUR changes (current branch)
  • Lines between ======= and >>>>>>> are THEIR changes (incoming branch)



To resolve: delete ALL three marker lines and keep the correct code:
const timeout = 3000; // chose incoming change

Then: git add <file> && git commit (or git merge --continue)

For three-way diffs, configure a merge tool:
git config --global merge.tool vimdiff

Why

Git inserts conflict markers to show both versions of a conflicting region. The markers are literal text in the file. You must remove them and choose the correct content before the file is valid.

Gotchas

  • Searching for '<<<<<<' in CI can catch accidentally committed conflict markers
  • Some editors (VS Code) highlight conflict markers with Accept Current/Accept Incoming buttons — use them
  • diff3 style shows the common ancestor too: git config --global merge.conflictstyle diff3

Code Snippets

Anatomy of a conflict marker and how to resolve it

<<<<<<< HEAD
const timeout = 5000;  // your change
=======
const timeout = 3000;  // their change
>>>>>>> feature/reduce-timeout

# After resolution (keep their change):
const timeout = 3000;

Conflict resolution commands

# Show diff3 style (includes common ancestor)
git config --global merge.conflictstyle diff3

# Check for leftover conflict markers
grep -r '<<<<<<<' src/

# After resolving, mark as resolved
git add src/config.js
git merge --continue

Context

When merging or rebasing branches that modified the same lines

Revisions (0)

No revisions yet.