DEV Community

Chris Achinga
Chris Achinga

Posted on

Syncing A forked Repo with the Parent Repo on GitHub

Syncing A forked Repo with the Parent Repo on GitHub

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

terminal2.png

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

git merge upstream/master
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

https://linktr.ee/chrisdev

Top comments (0)