Merge Conflict Resolution

Alex Niedre, 2016

Know culprits

  • Code in different branches is misaligned
  • Code is outdated
  • Changed were made without taking into consideration other people's work
  • General misunderstanding of what conflicts are and how they work in Git

What does a conflict look like?

<<<<<<< HEAD
    This is the version in your checked out branch
=======
    This is the version in the branch you're trying to merge
>>>>>>> master
  • The red parts is what indicates a conflict. It's just some text that Git doesn't know how to address.
  • Missing file or folders are the same thing, only in binary.
     

Tools

  • Git console
  • WinMerge
  • DiffMerge
  • PHPStorm

PHP Storm's Conflict Resolution tool

  • Efficient
  • Easy to understand
  • Provides a Three-Way-Merge option
  • Provides a possibility to view changes independently of either side: Left with Current, Right with Current, Either with a possible merge result.

Tips!

  • Everything you do until you've pushed is done only locally!
  • Unless you pushed your changes you can abort: git merge --abort
  • Unsure? Run php lint on files!
    • ​find ./ -name "*.php" | xargs php -l

Let's resolve a conflict!

Your typical conflict in phpStorm

Step 1

Step 2

Step 3

The dumbest conflict ever?

Compare different sides

Compare Right side and Result

Compare Left side and Result

What are the actual changes?

So... Do I care now?

Right side is not conflicting anymore

Git recursive merge conflict

git merge --diff-algorithm=[patience|minimal|histogram|myers]

And this...

Another hint

Merge Conflict Resolution

By Alex Niedre

Merge Conflict Resolution

  • 574