Lesson 1: The Cloud Vault (Remote Repositories)
So far, your Git repository lives only on your local machine. What happens if your laptop dies? What if your teammate needs the code? You need a remote repository — a copy of your project stored in the cloud.
What is a Remote?
A remote is a Git repository hosted on a server (GitHub, GitLab, Bitbucket). It acts as the single source of truth that your entire team shares.
Your Laptop GitHub (Remote) Teammate's Laptop
┌──────────┐ push → ┌──────────┐ ← clone ┌──────────┐
│ Local │ ──────────→ │ Origin │ ←────────── │ Local │
│ Repo │ ←────────── │ (cloud) │ ──────────→ │ Repo │
└──────────┘ ← pull └──────────┘ push → └──────────┘
Connecting to a Remote: git remote
git remote add origin https://github.com/cloudcorp/webapp.git
origin— The conventional name for the primary remote (you can name it anything).- The URL — Where the remote repository lives.
Key Remote Commands
| Command | What It Does |
|---------|-------------|
| git remote -v | List all remotes with URLs |
| git remote add <name> <url> | Connect to a new remote |
| git remote remove <name> | Disconnect a remote |
| git remote rename old new | Rename a remote |
Pushing Code: git push
Send your local commits to the remote:
git push origin main # Push main branch to origin
git push -u origin main # Push AND set up tracking (first time)
git push # Push to tracked remote (after -u)
The -u flag sets up tracking, so future pushes only need git push.
Pulling Code: git pull
Download and merge changes from the remote:
git pull origin main # Fetch + merge from remote
git pull # Pull from tracked remote
Cloning a Repository: git clone
Download an entire repository for the first time:
git clone https://github.com/cloudcorp/webapp.git
This creates a local copy with the full history and automatically sets up origin.
Mission Objective
Connect your project to the cloud:
- Connect: Add a remote with
git remote add origin https://github.com/cloudcorp/webapp.git. - Verify: Run
git remote -vto confirm the connection. - Clone: Practice cloning with
git clone https://github.com/cloudcorp/webapp.git.