paint-brush
Sync a Fork from Upstream Repo in GitHub!by@abhishekamralkar
3,393 reads
3,393 reads

Sync a Fork from Upstream Repo in GitHub!

by Abhishek AmralkarNovember 26th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Upstream repository is the Parent/Original repository from where you forked your repository.

Company Mentioned

Mention Thumbnail
featured image - Sync a Fork from Upstream Repo in GitHub!
Abhishek Amralkar HackerNoon profile picture

What is Upstream Repository in GIT?

Upstream repository is the Parent/Original repository from where you forked your repository.

What is Fork?

A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.

We will be see how we can sync and merge the Upstream repository changes in our own forked repository?


When a repository is cloned, it has a default remote called Origin that points to your fork on GitHub, not the original repository it was forked from.To keep track of the original repository, you need to add another remote named

How to configure a Upstream repository?

  • Change Directory to your fork repository on your local computer and run below command(please change the upstream when you run command)

git remote add upstream https://github.com/abhishekamralkar/emacs.d

You can verify it by below command

git remote -v

Below should be the output




origin [email protected]:abhishekamralkar/emacs.d.git (fetch)origin [email protected]:abhishekamralkar/emacs.d.git (push)upstream https://github.com/aa/emacs.d (fetch)upstream https://github.com/aa/emacs.d (push)

To sync the forked repository with the upstream repository follow below steps

  1. Fetch the branches and their respective commits from the upstream repository.

git fetch upstream

2. Check out your fork’s local master branch.

git checkout master

3. Merge the changes from upstream/master into your local master branch.

git merge upstream/master