Bitzu

GH-900 ยท Version control and Git

Remotes and syncing

Local versus remote repositories, origin, and the difference between git fetch, pull and push.

Key points

  • Your local repository is the copy on your machine; a remote is a copy hosted elsewhere, such as on GitHub.
  • When you clone, the remote is named origin by default. git fetch downloads new commits and updates remote-tracking branches like origin/main without changing your working files. git pull is a fetch followed by integrating the changes into your current branch. git push uploads your local commits to the remote.

Source: https://git-scm.com/docs/git-pull

Practice questions

Single choice

What is the default name Git gives the remote you cloned from?

  1. origin
  2. main
  3. upstream
  4. remote
Show answer

Answer: A. origin

git clone names the source remote origin unless you override it. main is a branch name, upstream is a convention for a forked source, and remote is not a default name.

Select all that apply

Which statements about fetch, pull and push are correct?

  1. git fetch downloads new commits without merging them into your branch
  2. git pull fetches and then integrates changes into the current branch
  3. git push uploads local commits to a remote
  4. git push downloads teammates' commits
  5. git fetch deletes your local commits
Show answer

Answer: A. git fetch downloads new commits without merging them into your branch, B. git pull fetches and then integrates changes into the current branch, C. git push uploads local commits to a remote

fetch downloads without integrating, pull fetches and then integrates, and push uploads local commits. push does not download changes.

True or false

True or false: making a commit on your computer automatically uploads it to the remote repository.

Show answer

Answer: False

False. A commit is local until you run git push.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More GH-900 topics in this module