Chapter 10. Merge Conflicts

[ 10 ]

Merge Conflicts

In Chapter 9, you carried out a three-way merge in which you did not experience any merge conflicts.

In this chapter, you’re going to learn about merge conflicts, how they arise, and how to resolve them by walking through a hands-on example of a three-way merge with a merge conflict.

State of the Local and Remote Repositories

At the start of this chapter, you should have two local repositories called rainbow and friend-rainbow and one remote repository called rainbow-remote. All three of these repositories should be in sync, with the same commits and branches. As usual, I recommend that you use two separate text editor windows and command line windows for working with the rainbow repository and the friend-rainbow repository.

Visualize it 10-1 shows the state of the local and remote repositories in the Rainbow project with all the commits that were made from Chapter 1 through Chapter 9.

To focus on the commits you are going to make in this chapter, from here on I’ll simplify the Visualize It diagrams and show only the last three commits that are part of the main branch in all the repositories: the blue commit, the brown commit, and the M1 merge commit. This representation is shown in Visualize it 10-2.

[ Visualize it 10-1 ]

figure

The Rainbow project at the start of Chapter 10 with all the commits since ...

Get Learning Git now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.