Git & Version Control Fundamentals

Lesson 4 of 5

Remotes: Push, Pull, and Clone

So far everything has lived only on your machine. A remote is a copy of your repository hosted somewhere else, usually GitHub, GitLab, or Bitbucket.

Connecting a remote

Create an empty repository on GitHub, then connect it to your local project:

git remote add origin https://github.com/you/my-project.git
git push -u origin main

-u (short for --set-upstream) links your local main branch to origin/main, so future pushes only need:

git push

Getting changes from a remote

git pull     # fetch + merge in one step
git fetch    # download changes without merging yet

Cloning an existing project

To get a full copy of someone else's repository:

git clone https://github.com/them/their-project.git

NOTE

origin is just a nickname, the default one Git suggests, but you can name a remote anything.

📝 Remotes Quiz

Passing score: 70%
  1. 1.Which command uploads your local commits to a remote repository?

  2. 2.Which command downloads a full copy of an existing remote repository?

  3. 3.The default name Git suggests for your primary remote is ____.