Remotes & GitHub
Module 06 — Remotes & GitHub
Goal: Connect your local repo to GitHub, understand
clone/push/fetch/pull, and see exactly what GitHub adds on top of plain Git.
6.1 What is a “remote”?
A remote is just another copy of your repository that lives somewhere else — usually on GitHub. Git lets you sync with remotes. The default remote is conventionally named origin.
Recall from Module 01: because Git is distributed, the remote isn’t special or “the master.” It’s a full copy that your team agrees to treat as the shared meeting point. Syncing with it is just copying objects (Module 04) back and forth.
git remote -v # list configured remotes and their URLs
git remote add origin git@github.com:you/my-repo.git # add one
That URL gets stored in .git/config under [remote "origin"] — the same file you read in Module 04.
6.2 Two ways to start
Start on GitHub, then clone down
Create an empty repo on GitHub (the “New repository” button), then copy it to your machine:
git clone git@github.com:you/my-repo.git
cd my-repo
clone downloads the entire history (all objects and refs), sets up origin automatically, and checks out the default branch. You’re ready to work instantly.
Start locally, then connect
If you already did git init locally (Module 03):
git remote add origin git@github.com:you/my-repo.git
git branch -M main # ensure your branch is named main
git push -u origin main # push and set up tracking
The -u (--set-upstream) tells your local main to track origin/main, so future git push/git pull need no arguments.
6.3 The four sync commands
git push — send your commits up
git push # once upstream is set
git push origin main # explicit form
Push uploads any local commits the remote doesn’t have, then moves the remote’s branch pointer forward. If someone else pushed in the meantime, Git rejects your push and tells you to pull first (so you never silently overwrite others’ work).
git fetch — download, but don’t merge
git fetch origin
Fetch downloads new commits from the remote into your refs/remotes/origin/... pointers, but does not touch your working files or current branch. It’s the “just show me what’s new, don’t change my work” command. Safe to run anytime.
git pull — fetch + integrate
git pull
pull is literally fetch followed by merge (or rebase, if you configured pull.rebase true). It downloads new commits and combines them into your current branch. This is what you run to get teammates’ latest work.
git clone — get a copy for the first time
Covered above; you only do this once per machine per project.
Local Remote (GitHub)
┌──────────┐ push ───► ┌──────────┐
│ commits │ │ commits │
│ │ ◄─── fetch │ │
└──────────┘ pull(=fetch+merge) └──────────┘
6.4 Tracking branches & origin/main
When you see origin/main, that’s Git’s local memory of where main was on the remote last time you synced. It lives in .git/refs/remotes/origin/main. It only updates when you fetch, pull, or push — so if it looks stale, just fetch.
git status
# "Your branch is ahead of 'origin/main' by 2 commits." -> you have unpushed work
# "Your branch is behind 'origin/main' by 3 commits." -> run git pull
6.5 What GitHub adds on top of Git
Everything so far is plain Git and would work with a USB stick as the “remote.” GitHub layers on collaboration and automation that Git itself doesn’t have:
- Hosting & access control — a reliable always-on home for your repos, public or private, with permissions.
- Pull Requests — a structured way to propose, discuss, and review changes before merging (Module 07).
- Issues & Projects — task tracking, bug reports, and planning boards tied to your code.
- Code review — line-by-line comments, approvals, required checks.
- GitHub Actions — automation that runs on events (test on every push, deploy on merge); Module 07.
- Releases & Packages — versioned downloads and package hosting.
- Security features — Dependabot alerts, secret scanning, vulnerability reports.
- GitHub Copilot — the AI assistant that’s the focus of Part C.
A useful way to hold it: Git gives you the time machine; GitHub gives you the collaboration building around it.
6.6 README, license, and the repo’s front page
A GitHub repo’s landing page renders the README.md from the root. A good README explains what the project is, how to install and run it, and how to contribute. Adding a LICENSE file declares how others may use your code. These are conventions GitHub surfaces nicely, not Git features.
Try it yourself
- Create an empty repo on GitHub.
- Connect your local repo from Module 03 with
git remote add origin ...andgit push -u origin main. - Edit the README on github.com directly (creating a commit on the remote), then run
git fetchandgit statuslocally — watch it say you’re “behind.” - Run
git pullto bring that change down. - Make a local commit and
git pushit. Refresh GitHub to see it appear.
Key takeaways
- A remote is another full copy of your repo; the default is
origin, stored in.git/config. clonecopies everything once;pushuploads;fetchdownloads without merging;pull= fetch + merge.origin/mainis your cached view of the remote’s branch; it updates only when you sync.- GitHub adds pull requests, issues, reviews, Actions, security, and Copilot on top of plain Git.