Upstream sync
- Git course
- Intermediate
- Lesson 55/82
- 4 min
Learn to sync with upstream after forking.
Upstream Synchronization
After creating a fork, new commits may be published in the original repository. To keep your fork updated, you can define the original repository as a remote named upstream. This lets you track updates from the source project.
origin → Your fork
upstream → Original repositoryFetch Updates from the Original Repository
First, you can add the original repository URL under the name upstream. Then git fetch upstream downloads information about new changes from that remote. Fetch does not directly merge those changes into your working files.
git remote add upstream https://github.com/original/project.git
git fetch upstreamPractice Fetch from Upstream
The original repository has already been added as upstream. Complete the Git command to retrieve its new commit information.
Starter code
# Kaynak depodaki güncellemeleri getirExpected output
From https://github.com/original/project * [new branch] main -> upstream/main
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which repository does upstream usually refer to in a fork workflow?
- A temporary folder on the computer
- The fork repository in your own account
- The original project Correct answer
- Git installation files
Explanation: Upstream refers to the original repository from which the fork was created. Origin is usually the URL of your own fork.
2 Fetch Information from the Original Repository
git fetch ____
git fetch upstream
Explanation: The fetch command retrieves updates from a remote repository without merging them.
3 Upstream Synchronization Concepts
| Term | Meaning |
|---|---|
origin |
Remote name for your own fork |
upstream |
Remote name for original repo |
fetch |
Downloads remote change info |
sync |
Keep fork updated with source project |