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.
Changes were merged into the upstream main branch that could conflict with changes in the pull request feature branches.
Diagram showing how merging the feature branch from one of the other forks’ feature branches into the upstream main branch results in a sequnce of commits that could conflict with the sequence of commits in your fork’s feature branch.
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Β Let’s Do it Again 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 the 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 contains changes that will 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.
(d)
Which of the following messages do you see?
  • GitHub message indicating that merging can be performed automatically.πŸ”—
    Image of a dialog with a green checkmark and the message "This branch has no conflicts with the base branch. 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Β Appendix A 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.
  • GitHub message indicating that there are merge conflicts that must be resolved.πŸ”—
    Image of a dialog with a exclamation point inside a triangle and the message "This branch has conflicts that must be resolved. Use the web editor or the command line to resolve conflicts."
  • Correct! 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.
Hint.
If you don’t see a message make sure you completed your pull request. If you have questions, please ask your instructor to verify your merge request has been created properly.

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 of activities on this page.