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: