Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Christophe Colombier
Christophe Colombier

Posted on

     

Better git conflicts: zdiff3

Let's talk about git conflicts.

OK, we hate them 😅, but let move on.

You may have faced to the classic way for git to report issue.

Here are lines that are either unchanged from the commonancestor, or cleanly resolved because only one side changed,or cleanly resolved because both sides changed the same way.<<<<<<< yours:sample.txtConflict resolution is hard;let's go shopping.=======Git makes conflict resolution easy.>>>>>>> theirs:sample.txtAnd here is another line that is cleanly resolved or unmodified.
Enter fullscreen modeExit fullscreen mode

It's convient, BUT you can have something better by activating this git config setting

git config --global merge.conflictstyle zdiff3
Enter fullscreen modeExit fullscreen mode

You will find more information in the manualhttps://git-scm.com/docs/git-merge/2.38.0#_how_conflicts_are_presented

The zdiff3 is a zealous variation of diff3 that exists for a while now.

Here are lines that are either unchanged from the commonancestor, or cleanly resolved because only one side changed,or cleanly resolved because both sides changed the same way.<<<<<<< yours:sample.txtConflict resolution is hard;let's go shopping.||||||| base:sample.txtor cleanly resolved because both sides changed identically.Conflict resolution is hard.=======Git makes conflict resolution easy.>>>>>>> theirs:sample.txtAnd here is another line that is cleanly resolved or unmodified.
Enter fullscreen modeExit fullscreen mode

This mode allows you to get more context about the conflict.

It helped me a lot since I started using last year.

Top comments(2)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
hasibrashid profile image
Hasib Al Rashid
Just a Casual Programmer addicted to Coffee 😋
  • Location
    Dhaka, Bangladesh
  • Education
    Mirzapur Cadet College
  • Pronouns
    he, him
  • Work
    Student
  • Joined

It is a really helpful post! Learned alot from it 👍

CollapseExpand
 
ccoveille profile image
Christophe Colombier
Smiling person, father of two, Husband, Senior Developer/Architect (in that exact order, it's important)Experience in development since 2004Linux user and advocate since 2001
  • Location
    Villeurbanne, France
  • Education
    Arts et Métiers
  • Work
    VP Technology
  • Joined

If you want more information I recommend this detailed article

neg4n.dev/blog/understanding-zealo...

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Smiling person, father of two, Husband, Senior Developer/Architect (in that exact order, it's important)Experience in development since 2004Linux user and advocate since 2001
  • Location
    Villeurbanne, France
  • Education
    Arts et Métiers
  • Work
    VP Technology
  • Joined

More fromChristophe Colombier

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp