DEV Community

Discussion on: Another conflict: resolving conflicts in git that occur when using rebase.

Collapse
 
oscherler profile image
Olivier “Ölbaum” Scherler • Edited

Great article!

Additional tip: the first thing I do when I configure git in a new environment is to change the conflict markers:

git config --global  merge.conflictstyle diff3

It turns this:

<<<<<<< HEAD
I am Jacqueline Binya, I am a coding enthusiast, and an art lover.
=======
I am Jacqueline Binya, I am a coding enthusiast, and a paintball master.

My interests include:
- Cooking
- Fitness
- Travelling
>>>>>>> list-interests

into this (Case A):

<<<<<<< HEAD
I am Jacqueline Binya, I am a coding enthusiast, and an art lover.
||||||| merged common ancestors
I am Jacqueline Binya, I am a coding enthusiast, and anart lover.
=======
I am Jacqueline Binya, I am a coding enthusiast, and a paintball master.

My interests include:
- Cooking
- Fitness
- Travelling
>>>>>>> list-interests

or this (Case B):

<<<<<<< HEAD
I am Jacqueline Binya, I am a coding enthusiast, and an art lover.
||||||| merged common ancestors
I am Jacqueline Binya, I am a coding enthusiast, and rocket scientist.
=======
I am Jacqueline Binya, I am a coding enthusiast, and a paintball master.

My interests include:
- Cooking
- Fitness
- Travelling
>>>>>>> list-interests

The middle section (“merged common ancestors”) is what was there before each side’s change. So you can see better what happened.

In Case A, we see that the change on master was to correct a typo, and the change on list-interests was to replace “art lover” with “paintball master”, and to add the list of interests. So solving the conflict in a way that preserves the intents of both sides means:

I am Jacqueline Binya, I am a coding enthusiast, and a paintball master.

My interests include:
- Cooking
- Fitness
- Travelling

In Case B, however, the change on master was to replace “rocket scientist” with “art lover”. while the change on list-interests was to replace “rocket scientist” with “paintball master” and add the list of interests. So solving the conflict in a way that preserves the intents of both sides probably means something like:

I am Jacqueline Binya, I am a coding enthusiast, an art lover, and a paintball master.

My interests include:
- Cooking
- Fitness
- Travelling

Or it might be needed to consult with the other person to decide whether “rocket scientist” is better replaced with “art lover” or “paintball master”.

With the default config of merge.conflictstyle = merge, you get the same output for the conflict in both cases, and it’s much harder in my opinion to figure out what was the intent on both sides.

This simple config change made conflict resolution much less of a headache for me.

Collapse
 
syntaxseed profile image
SyntaxSeed (Sherri W)

This is great!!

Collapse
 
jacqueline profile image
Jacqueline Binya

Thank you loads.
Your suggestion is really dope and indeed as you said if you can see the initial state before the changes, resolution becomes way easier.
I will definitely start implementing this approach.:)