Lesson 4 • Intermediate
Working with Remote Repositories 🌿
Push code to GitHub, pull teammates' changes, create pull requests, and contribute to open source — the collaboration skills every developer needs.
What You'll Learn in This Lesson
- • What remotes are and how
originworks - •
git push,git pull, andgit fetch - • Pull requests and code review workflows
- • Forking and contributing to open source
- • Keeping your fork synced with upstream
push uploads your changes, and pull downloads everyone else's. GitHub is just the cloud storage for your code.1️⃣ Remote Basics
A remote is a version of your repository hosted on a server (GitHub, GitLab, Bitbucket). The default remote created by git clone is called origin. You can have multiple remotes pointing to different servers.
Try It: Remote Basics
View, add, and understand remote connections
// Remote Repositories — Collaborate with Others
console.log("=== What Are Remotes? ===");
console.log("A remote is a copy of your repository on a server.");
console.log("GitHub, GitLab, and Bitbucket host remotes.");
console.log("The default remote is called 'origin'.");
console.log();
console.log("=== Viewing Remotes ===");
console.log(" $ git remote -v");
console.log(" origin https://github.com/you/project.git (fetch)");
console.log(" origin https://github.com/you/project.git (push)");
...2️⃣ Push, Pull, and Fetch
git push uploads your commits. git pull downloads and merges. git fetch downloads without merging — useful when you want to inspect changes before integrating them.
Try It: Push & Pull
Sync your local and remote repositories
// git push & git pull — Syncing with Remote
console.log("=== git push — Upload Your Work ===");
console.log();
console.log(" $ git push origin main");
console.log(" → Uploads your main branch commits to origin (GitHub)");
console.log();
console.log(" First push of a new branch:");
console.log(" $ git push -u origin feature-login");
console.log(" → '-u' sets upstream tracking (git push works alone next time)");
console.log();
console.log("=== git pull — Download & Merge ===");
console.log(
...3️⃣ Pull Requests
Pull requests are the standard way to propose changes on GitHub. They enable code review, discussion, and automated testing before changes are merged into the main branch.
Try It: Pull Requests
The complete PR workflow from branch to merge
// Pull Requests — Code Review Workflow
console.log("=== What is a Pull Request (PR)? ===");
console.log("A PR is a REQUEST to merge your branch into another branch.");
console.log("It's where code review, discussion, and CI/CD happen.");
console.log("(Called 'Merge Request' on GitLab)");
console.log();
console.log("=== PR Workflow ===");
const prSteps = [
"Create a feature branch",
"Make commits on that branch",
"Push branch to GitHub",
"Open a Pull Request (PR) on GitHub",
"Team rev
...4️⃣ Forking & Open Source
Forking creates your own copy of someone else's repository. It's how you contribute to open source — fork, clone, branch, commit, push, then open a PR back to the original project.
Try It: Forking
Contribute to open source with forks and upstream remotes
// Forking & Contributing to Open Source
console.log("=== Forking — Your Copy of Someone Else's Repo ===");
console.log();
console.log("A fork is a personal copy of another user's repository.");
console.log("You can freely experiment without affecting the original.");
console.log();
console.log("=== Open Source Contribution Workflow ===");
const forkSteps = [
{ step: "Fork the repository on GitHub", cmd: "(Click 'Fork' button)" },
{ step: "Clone YOUR fork", cmd: "git clone https://github.co
...⚠️ Common Mistakes
git pull --rebase instead of git pull to keep a cleaner history when pulling remote changes.📋 Quick Reference
| Command | Purpose |
|---|---|
| git remote -v | List remotes |
| git push origin main | Upload commits |
| git pull origin main | Download & merge |
| git fetch origin | Download only |
| git push -u origin branch | First push + tracking |
| git remote add name URL | Add new remote |
🎉 Lesson Complete!
You can now push, pull, and collaborate with remote repositories! Next, we'll tackle the most feared Git topic — resolving merge conflicts.
Sign up for free to track which lessons you've completed and get learning reminders.