MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Syncing Upstream Repositories and Keeping Forks Updated0%
Study Materials
Git & GitHub BasicsProgress 0%
1.1What is Version Control? (Local, Centralized vs Distributed VCS)1.2Why Git? History, Architecture & Core Benefits1.3The Three Trees: Working Directory, Staging Area & Git Repository1.4Installing Git and Initial Configuration (git config user.name / email)
6.1Forking Repositories and Cloning to Local Machine (git clone)6.2Creating and Managing Pull Requests (PRs) on GitHub6.3Code Reviews, Inline Comments, Approvals and Changes Requested6.4Syncing Upstream Repositories and Keeping Forks Updated
HomeTutorialsGit & GitHub BasicsSyncing Upstream Repositories and Keeping Forks Updated
Shelving Changes Temporarily with git stash (save, pop, apply, drop)

Syncing Upstream Repositories and Keeping Forks Updated

Beginner12 min read•Updated: 2026-09-15•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

When contributing to open-source software, hundreds of developers may merge code into the original project every week. If your personal fork falls behind, you will encounter merge conflicts and outdated code. Keeping your fork in sync with the original repository (called upstream) is a vital skill.


1. The Multi-Remote Topology: origin vs upstream

When you work on a fork, your local machine communicates with two different remote repositories:

1[ Original Project ] (e.g. github.com/facebook/react)
2 ^
3 | upstream (read-only for you)
4 |
5[ Your Local Machine ] (D:/projects/react)
6 |
7 | origin (your read-and-write fork)
8 v
9[ Your Personal Fork ] (e.g. github.com/sumit-msk/react)
  • origin: Points to your personal fork on GitHub. You have write/push access here.
  • upstream: Points to the original canonical repository. You read/fetch updates from here.

2. Setting Up the upstream Remote

When you first clone your personal fork, Git only knows about origin:

1git remote -v
2# Output:
3# origin git@github.com:sumit-msk/react.git (fetch)
4# origin git@github.com:sumit-msk/react.git (push)

Adding the Original Project as upstream:

1git remote add upstream git@github.com:facebook/react.git

Verify Both Remotes:

1git remote -v
2# Output:
3# origin git@github.com:sumit-msk/react.git (fetch)
4# origin git@github.com:sumit-msk/react.git (push)
5# upstream git@github.com:facebook/react.git (fetch)
6# upstream git@github.com:facebook/react.git (push)

3. The 4-Step Terminal Sync Workflow

Whenever you sit down to write new code or before opening a PR, sync your local main branch with upstream:

1# Step 1: Switch to your local main branch
2git switch main
3 
4# Step 2: Fetch all latest branches and commits from upstream
5git fetch upstream
6 
7# Step 3: Fast-forward merge upstream/main into your local main
8git merge upstream/main
9 
10# Step 4: Push the updated main to your personal GitHub fork (origin)
11git push origin main

Your local repository AND your personal fork on GitHub are now 100% up-to-date with the original open-source project!


4. Alternative: GitHub Web UI "Sync Fork" Button

GitHub also provides a convenient web button on your fork's homepage:

  1. 1
    Navigate to your fork repository on GitHub (github.com/your-username/repo-name).
  2. 2
    Under the repository header, look for:

"This branch is 12 commits behind upstream:main".

  1. 1
    Click the Sync fork button -> Update branch.
  2. 2
    Then, pull down the updates to your laptop:
1 git switch main
2 git pull origin main

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
In open-source Git workflows, what does the remote alias upstream conventionally refer to?
Question 2
What command configures the original repository as an upstream remote?
Question 3
What is the recommended terminal sequence to pull in upstream updates to your local main branch?
Question 4
Why is it crucial to sync your fork before starting work on a new feature?
Question 5
After merging upstream/main into your local main, why should you run git push origin main?
Next Lesson

Shelving Changes Temporarily with git stash (save, pop, apply, drop)

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Code Reviews, Inline Comments, Approvals and Changes RequestedShelving Changes Temporarily with git stash (save, pop, apply, drop)

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master Git & GitHub Basics with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext