Full Byte Developer.

See the original version in merge conflicts

One line in Git config adds a third section to conflict markers so you can see what both sides started from.

Published here · 2 sources

The default conflict marker shows two versions: yours and theirs. You guess what they started from. One line in Git config adds the original, so you know what both sides changed.

Set the conflict style

Run this once. It applies to every repo.

bash
git config --global merge.conflictStyle zdiff3

What you see in a conflict

A conflict in server.js now shows three sections:

text
<<<<<<< HEAD
const port = 3000;
||||||| parent of abc1234
const port = 8080;
=======
const port = 8000;
>>>>>>> feature

The middle section (|||||||) is the original before either branch touched it. HEAD changed 8080 to 3000. Feature changed 8080 to 8000.

Read it this way

  • Top: your version (HEAD).
  • Middle: what they both started from (the merge base).
  • Bottom: the other branch.

Knowing the original tells you whether one side added lines, deleted lines, or both sides edited the same line differently.

Why zdiff3 over diff3

Both styles show the original. zdiff3 trims unchanged prefix and suffix lines so the original section is shorter in big conflicts. Same information, less scrolling.

Send this to the friend who stares at merge conflicts guessing what the original code was.

Keep this guide

By Full Byte Developer

Filed under Dev tools

Questions about this guide

What is the difference between diff3 and zdiff3?

zdiff3 removes unchanged prefix and suffix lines from the original section. Same information, less noise in big conflicts.

Does this change how rebases work?

Yes. The conflict markers show the original during rebases and cherry-picks too.

Sources

Next in this stack