Tour of Git
Working with Remotes / Lesson 4.1

What are Remotes?

A remote is a copy of your repository hosted somewhere else — usually on a server like GitHub, GitLab, or Bitbucket. Remotes enable collaboration: they're how you share work and get updates from others.

The Collaboration Model

Your Machine          GitHub             Teammate's Machine
┌──────────┐      ┌──────────┐       ┌──────────┐
│  Local    │ push │  Remote  │  pull │  Local    │
│  Repo     │ ──→  │  (origin)│  ←──  │  Repo     │
│           │ pull │          │  push │           │
│           │ ←──  │          │  ──→  │           │
└──────────┘      └──────────┘       └──────────┘

Key Commands

  • git clone — Copy a remote repository to your machine
  • git remote — Manage connections to remote repositories
  • git push — Upload your commits to a remote
  • git pull — Download and merge remote changes
  • git fetch — Download remote changes without merging

Origin

When you clone a repository, Git automatically names the remote origin. This is just a convention — you can have multiple remotes with any names.

Remote Tracking Branches

When you fetch or pull, Git creates remote tracking branches like origin/main. These are read-only snapshots of where the remote's branches were last time you synced.

main           → your local branch (you commit here)
origin/main    → where origin's main was when you last fetched

Typical Workflow

  1. git pull — Get latest changes from the team
  2. Make your changes, commit locally
  3. git push — Share your commits with the team

In the next lessons, you'll practice each step of this workflow.