Skip to main content

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

Section 4.2 Overview of Synchronizing with the Upstream Repository

As you saw in Section 4.1, as changes from pull requests (yours and others) are merged into upstream main, the main branches in your local and origin repos will get out of synch with the upstream.
Now, recall that upstream main should be the starting point for all new work. So, before you can work on something new, you’ll need to ensure that your main branches look like the upstream main (i.e. you will synchronize them with the upstream). This is a two-step process. First, you will pull the upstream main into your local repository and then you will push it to your origin. Figure 4.2.1 shows how pulling main from the upstream and then pushing it to your origin synchronizes the main branches.
described in detail following the image
Cloud image showing how the main branches of the local and origin repository are synchronized with the upstream.
Figure 4.2.1. Synchronizing the local and origin main branches with the upstream.

Exercises

1.

Answer the following questions using Figure 4.2.1
(a)
    Which action will copy changes from the upstream repository to your local repository?
  • Pushing to your origin.
  • The push operation copies changes from your local repository to a remote repository.
  • Pulling from your origin.
  • The pull operation copies changes from a remote repository to your local repo. But which remote repo do you need to copy from?
  • Pushing to the upstream.
  • The push operation copies changes from your local repository to a remote repository. But, recall that you do not have permission to push to upstream.
  • Pulling from the upstream .
  • Correct. Pulling from the upstream copies the changes that have been merged into upstream into your local repository.
  • Switching to your feature branch.
  • Switching branches does not move information between your local repository and a remote repository.
Hint.
Look back to at the figure to see which arrow goes from the upstream to your local repository.
(b)
    Which action copies changes from your local repository to your origin repository?
  • Pushing to your origin.
  • Correct. Pushing to your origin will copy changes from your local repository to your origin repository.
  • Pulling from your origin.
  • Pulling copies changes from a remote repository into your local repository.
  • Pushing to the upstream.
  • Pushing copies changes from your local repository to a remote repository. But recall that you do not have permission to push to upstream main.
  • Pulling from the upstream.
  • Correct. Pulling from the upstream copies changes that have been merged into the upstream to your local repository.
  • Switching to your feature branch.
  • Switching branches does not move information between your local repository and a remote repository.
Hint.
Look back to at the figure to see which arrow goes from your local repository to the origin.
You have attempted 1 of 3 activities on this page.