
Hi, I’m Pandu. I’m an engineer who’s worked in full-stack and frontend roles in 2016, doing full-time roles at companies like Crunchbase and freelance work for tiny startups. I just joined Apsis this June. Here’s something you might not know!
Unless you’re working on a project all by yourself, chances are you run into merge conflicts every now and then. Here’s a small config option in Git that can make your life easier.
Pop quiz!
Two developers both made changes to this line, resulting in a merge conflict.
What’s the correct resolution to the conflict?
<<<<<<<
HELLO WORLD
=======
hello world!
>>>>>>>
Take a moment to come up with an answer and then scroll down to see the solution. Here are some options:
A) hello world
B) HELLO WORLD!
C) Hello world
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The right answer is:
D) We don’t have enough information to say!
It depends on the context: What was the original version before both changes? There are two possible scenarios:

The solution: diff3
The diff3
option adds an extra section to your merge conflicts. Let’s take a look at our conflict again using that option:
<<<<<<<
HELLO WORLD
|||||||
HELLO WORLD!
=======
hello world!
>>>>>>>
The middle section is the new one: It’s the original version before both changes.
Now we can tell what the answer is. (View the solution)
Enabling diff3
To use this option, run this command: (Or manually modify your gitconfig
file)
git config --global merge.conflictstyle diff3
Sometimes the extra section isn’t necessary, but other times (like we just saw), it’s basically required to solve a conflict. But even when it’s not strictly necessary, it can be really helpful to make conflicts easier and avoid making a mistake. Good luck!