Syncing A forked Repo with the Parent Repo on GitHub

Syncing A forked Repo with the Parent Repo on GitHub

Chris Achinga
·Jan 1, 2021·

2 min read

Subscribe to my newsletter and never miss my upcoming articles

A short guide and a practical reference to GitHub Documentation on syncing a repo.

It's kind of an 'open-source' hacks

For the guide, I'll be using a repo I forked from FbDevcCommunityContent.

From the terminal, I will change my directory to where the project files are:

terminal.png

The first step will be to fetch branches and their commits from the upstream, or the parent repository:

git fetch upstream

terminal1.png

After that, ensure that you are at the default repository on your remote repo. In my case, the default branch is master, and so is the upstream.

To confirm your current branch you are on:

git status

terminal2.png

All set so go ahead and merge with the upstream's master branch:

git merge upstream/master

If you haven't made any changes or commits on your master branch, git will automatically merge the repos and it'll be up to date

terminal3.png

Once that is done, update your remote files to GitHub:

git add .
git commit -m 'synced repo with upstream'
git push

push.png

Well, that's pretty much it. Find the original documentation here:

https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/syncing-a-fork

linktr.ee/chrisdev

 
Share this