Skip to main content

GitKit (Linux Desktop Edition): Learn git and GitHub in Context

Section 4.4 Pulling the Upstream main Branch

Exercises

1.

main
(a)
    To pull the changes from the upstream main branch into your local repo you first need to ensure that main is the active branch in your local repo. Check the active branch in your local repo. What command did you use?
  • git log
  • The git log command tells you the commits made to the active branch.
  • git branch main
  • The git branch main command will create a new branch with the name main.
  • git status
  • Correct! The git status command tells you active branch.
  • git switch main
  • The git switch main command will change the active branch to main, not check what is the active branch.
Hint.
Refer back to the section in the previous chapter on switching branches Section 3.3
(b)
    If your active branch in not the main branch change the active branch now. What command changes the active branch to main?
  • git log
  • The git log command tells you the commits made to the active branch.
  • git branch main
  • The git branch main command will create a new branch with the name main.
  • git status
  • The git status command tells you active branch, it does not switch branches.
  • git switch main
  • Correct! The git switch main command will change the active branch to main.
Hint.
Refer back to the section in the previous chapter on switching branches Section 3.3
(c)
The command
git pull --ff-only <remote repo name> <branch>
will pull any new commits from the specified branch in the remote repo and add them onto the end of the active branch of your local repo. Use the git pull command above to pull and add the commits from the main branch of the upstream repo to your main branch.
(d)
    Examine the output from Task 4.4.1.b. It should not contain any error messages. If it does, return to Task 4.4.1.b and try again. Which of the following is shown in the output of the git pull command?
  • The file(s) that were changed.
  • The number of additions to the files.
  • The URL of upstream.
  • The number of deletions to the files.
  • All of the branches in your local repository.
Hint.
Make sure you look at all of the lines of output and the color coding of the lines.
You have attempted of activities on this page.