Git & GitHub · Lesson 76 of 144
Keeping a Fork Updated
The upstream remote.
The original project keeps moving. New commits arrive every day, but your fork doesn't get them automatically. To keep up, you add a second remote, pointing to the original. By tradition, it's called upstream.

- The original keeps moving
- Your fork falls behind
- Add a remote called upstream
Adding upstream
Git remote add upstream, with the original project's address. Now git remote dash v shows two remotes. Origin is our fork. Upstream is the original.
git
git remote add upstream https://github.com/octo/awesome-tips.git git remote -v origin https://github.com/sam/awesome-tips.git (fetch) origin https://github.com/sam/awesome-tips.git (push) upstream https://github.com/octo/awesome-tips.git (fetch) upstream https://github.com/octo/awesome-tips.git (push)
Syncing
The original project got a new tip. To bring it in, git fetch upstream. Then merge upstream slash main into our main. Finally push, so our fork on GitHub is up to date too.
git
git fetch upstream From https://github.com/octo/awesome-tips * [new branch] main -> upstream/main git merge upstream/main Updating b06f74c..c0a9ac0 Fast-forward tips.md | 1 + 1 file changed, 1 insertion(+) git push To https://github.com/sam/awesome-tips.git b06f74c..c0a9ac0 main -> main
Summary
Add the original as upstream. Fetch upstream, merge upstream slash main, then push to your fork. Next, your first open source contribution.
Key takeaways- git remote add upstream <url>
- git fetch upstream
- git merge upstream/main
Next up: Contributing to Open Source — a friendly first pull request