Skip to main content

GitKit (2nd ed.): Learn git and GitHub in Context

Section 5.2 Confirming the Merge Conflict

While you were working on your Round2 issue your instructor, playing the role of a maintainer, merged some changes into the upstream main. These changes were merged after you created the feature branch for your Round2 issue. This situation is illustrated in Figure 5.2.1.
described in detail following the image
Changes were merged into the upstream main branch that could conflict with changes in the pull request feature branches.
Figure 5.2.1. Conflicting Upstream Changes.
The changes that your instructor merged were specifically designed to create a conflict with the change that you made when you fixed your Round2 issue. Thus, the pull request you made in Section 4.8 now contains a conflicting change and therefore cannot be merged automatically.
The activities in the remainder of this section will reinforce your understanding of how the conflict arose, confirm that your main branch is out of synch with the upstream, and that your pull request cannot be merged automatically.

Exercises

1.

Complete the following tasks that ask about the current situation, which is illustrated in Figure 5.2.1.
(a)
    Which of the following commits (i.e. which color) in Figure 5.2.1 did the instructor add to the upstream main branch after you created the feature branch for your Round2 issue?
  • Dark Blue
  • Correct.
  • Lime Green
  • The lime green commit is not in the upstream main branch.
  • Brown
  • The brown commit is not in the upstream main branch.
  • Light Blue
  • The light blue commit was added to the upstream main before the contributors created their feature branches.
  • Yellow
  • The yellow commit was added to the upstream main before the contributors created their feature branches.
Hint.
Look at which commits are in upstream main branch that are not in the contributors’ main branches.
(b)
    Which of the following commits (i.e. which color) in Figure 5.2.1 did you create that will create a merge conflict with the upstream main branch?
  • Dark Blue
  • The dark blue commit is already in the upstream main branch.
  • Lime Green
  • The lime green commit might create a merge conflict, but it is not your commit.
  • Brown
  • Correct!
  • Light Blue
  • The light blue commit is already in the upstream main branch.
  • Yellow
  • The yellow commit is already in the upstream main branch.
Hint.
Look for a commit in your local repository that might contain changes that could conflict with the changes in the dark blue commit.

2.

If everything is as we saw above, then the pull request that you created for your Round2 issue will contain a merge conflict with the upstream main branch. Let’s confirm that it does before going on.
(a)
Visit the upstream repo on GitHub, click on the "Pull requests" tab.
(b)
Find and click on your Round2 pull request.
(c)
Scroll down toward the bottom of the pull request.
(d)
    Which of the following messages do you see?
  • described in detail following the image
    GitHub message indicating that merging can be performed automatically.
  • IMPORTANT: You should be seeing that your pull request cannot be merged automatically. Follow the instructions in Section 5.11 to fix this problem.
    When your pull request cannot be merged automatically, return to this question and continue. See your instructor if you cannot resolve this problem.
  • described in detail following the image
    GitHub message indicating that there are merge conflicts that must be resolved.
  • Excellent. Everything is as it should be. Please continue to the next exercise.
  • I don’t see either of the other messages.
  • If you see a message about GitHub checking if the merge can be performed automatically, wait a few moments for one of the other messages to appear.

3.

We now know that your Round2 pull request contains a merge conflict and cannot be merged automatically. Place the following actions into an order which could have created this merge conflict.
Hint 1.
For a conflict to occur the upstream main branch must contain changes that are not in your feature branch.
Hint 2.
When would you have to create your feature branch for the upstream main branch to contain changes that are not in your feature branch.
You have attempted 1 of 4 activities on this page.