Skip to main content

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

Section 4.1 Understanding Changes to the Upstream Repository

If the upstream maintainers decide that the changes in your PR (pull request) are good for the project, they will merge them into the upstream main branch. That way they become a part of the main project, and everyone can benefit from your work. In class your instructor played the role of a maintainer and demonstrated how the changes contained in pull requests are merged into the upstream. Figure 4.1.1 shows the upstream with several new changes merged into its main branch.

Exercises

Figure 4.1.1 illustrates the state after several commits have been merged into upstream main.
described in detail following the image
Cloud image showing some changes merged into the upstream main branch.
Figure 4.1.1. Changes Merged into Upstream.

1.

Answer the following questions using Figure 4.1.1
(a)
    Which commits (give the colors) were merged into the upstream main after the contributor created their local feature branch?
  • Red
  • Yellow
  • Green
  • Blue
  • Pink
  • Lime Green
Hint.
Look at which commits are in the upstream main branch that are not part of the local repository’s main branch.
(b)
    Which of the commits did the managers merge from the contributor’s pull request?
  • Red
  • Red was in main prior to the contributor creating the feature branch.
  • Yellow
  • Yellow was in main prior to the contributor creating the feature branch.
  • Green
  • Green was in main prior to the contributor creating the feature branch.
  • Blue
  • Correct. Blue was part of the contributor’s feature branch.
  • Pink
  • Pink was part of another contributor’s pull request.
  • Lime Green
  • Lime green was part of another contributor’s pull request.
Hint.
Look at which commits are in the local repository’s feature branch.
(c)
    Which of the following statements explains how the pink commit might have gotten into the upstream main branch?
  • The contributor made the pink commit to their feature branch.
  • The contributor’s feature branch did not contain the pink commit.
  • A maintainer merged the contributor’s pull request.
  • The contributor’s pull request contained the blue commit, not the pink commit.
  • A maintainer merged a pull request from another contributor which contained the pink commit.
  • Correct. The pink commit was part of a feature branch that another contributor submitted via a pull request.
  • The pink commit is not part of the upstream main.
  • The pink commit is part of the upstream main. It was merged after the pull request that contained the blue commit.
Hint.
Look at which commits are in the local repository’s feature branch. This shows the changes made by this contributor. Other changes were made by other contributors and accepted by the maintainer as a pull request.

2.

At this point the upstream main branch should have changes that are not contained in your origin and local main branches. That is, you are out of synch with the upstream. When your origin repository is out of synch with the upstream, GitHub will display a message that informs you. Let’s investigate this message.
(a)
    Use your browser to visit your origin repo on GitHub and ensure that the main branch is selected.
    Which of the following messages do you see that indicates that your origin’s main branch is behind the upstream main?
  • This branch is x commits behind main.
  • Correct! Being behind means that the upstream main branch contains changes that your origin main branch does not.
  • This branch is x commits ahead of main.
  • Being ahead means that your origin main branch contains changes that are not in the upstream main branch. However, right now your origin main should be behind the upstream main branch.
    You will need to fix this before continuing. Go to Section 4.10 of this chapter and follow the instructions there. Once you complete Section 4.10, return to this exercise.
  • I do not see either of those messages.
  • Seeing no message indicates that origin main branch is up to date with (i.e. identical to) the upstream main branch. However, Right now your origin main should be behind the upstream main branch.
    You will need to fix this before continuing. Go to Section 4.10 of this chapter and follow the instructions there. Once you complete Section 4.10, return to this exercise.
Hint.
You can find the relevant message in a box just below the branch name drop down near the top left of your origin’s GitHub page.
(b)
    Which of the following statements describes what could have happened to cause your origin’s main branch to get behind the upstream main?
  • Another contributor has made a pull request to the upstream for changes that they have made.
  • In order for this to affect the upstream main a maintainer would have to have merged their pull request.
  • You have made a pull request to the upstream for a feature branch on which you have been working.
  • In order for this to affect the upstream main a maintainer would have to have merged your pull request.
  • You have committed changes to your local main branch and pushed it to your origin.
  • Here your origin main branch would contain changes that are not in the upstream main branch, so your branch would be ahead, not behind.
  • A maintainer merged a pull request and you have not yet updated your origin’s main branch to include these changes.
  • Correct. The manager merging the pull request will add changes to the upstream main branch that are not in your main branches.
Hint.
Think about how changes may been added to the upstream main after you made your feature branch, and while you were working.
You have attempted 1 of 6 activities on this page.