CurriculumRemote RepositoriesManaging Multiple Remotes
Lesson 7 of 7100%
Intermediate6 min+60 XP

Managing Multiple Remotes

A single Git repository can connect to multiple remotes simultaneously. The most common use case is open source contribution: "origin" points to your personal fork and "upstream" points to the original project.

01.The Fork + Upstream Workflow

Classic open source setup: Fork the project on GitHub (creates your copy under your account). Clone your fork — this sets origin to your fork automatically. Add the original repo as "upstream". You push your work to origin (your fork) and open pull requests. You sync from upstream to stay current with the original project.

Distributed Architecture
💻
Your Local
push / pull
☁️
GitHub (Remote)
push / pull
💻
Teammate's Local

02.Keeping Your Fork in Sync

When the original project gets new commits, you need to sync. Fetch from upstream to download new commits into remote-tracking branches. Then merge or rebase upstream/main into your local main. Then push to origin to update your fork on GitHub. This is the complete sync loop.

Branch Visualization
featuremainHEAD
main
feature
HEAD

Commands

commands — click to reveal output
$
git remote add upstream https://github.com/original/repo.git
Add the original repo as upstream
$
git remote -v
Verify both remotes are configured
▼ show output
$
git fetch upstream
Download latest commits from the original project
$
git rebase upstream/main
Replay your work on top of the latest original main
$
git push origin main
Update your fork on GitHub with the synced changes
KNOWLEDGE CHECK

In open source contribution, what does "upstream" typically refer to?

Rate this lesson:
PreviousNext Lesson