Do you know how to sync your fork to the original repository via the browser?

Hansika Wanniarachchi
Nov 2 ¡ 3 min read
Photo on Code Affine

Sometime you can meet the situation that you fork a repository and you contribute to it, then it could happen that your fork and the upstream are not in sync anymore. In my previous blog post I explained how face that kind of situation by adding remote upstream.

Today i’m going to talks about sync your fork to the original repository via the browser. When you create a fork of a repository, you only have the versions of the files that are in the repository at that time. So if there are any changes in the original repository you may find that your fork is out of sync.

This can lead to problems when you try to create a pull request. While GitHub has instructions for merging an upstream repository into your fork they require you to have git installed on your local machine.😔 Therefore i search that if there is any other simply way to done with the browser rather using installing git locally.

Fortunately I found that on Stack Overflow answer, there is another simple way which can update your fork in the browser by following the easy steps.

  1. Open your fork of the repository.
  2. Click the compare button.

3. This will open a page titled Comparing Changes and if you look carefully you’ll have jumped to the upstream version of the repository. If you were to do a regular pull request then this makes sense as you’d be bringing your changes into the upstream version. But in this case we want to flip the direction and pull changes from the original version to our fork.

4. Change the base fork to your repository

5. You’re now back to your fork but you’ve also asked to compare two identical repositories so GitHub thinks you care about branches not forks. Click on compare across forks to get back your base fork option.

6. Change the head fork to the upstream (original) repository

Note at this point that if you were in control of everything at GitHub you would probably just have put a little button in between the base for and head fork that would have flipped them for you rather than doing all these clicks. You might even had added in a separate button to check for upstream changes! But they do know that this is a bit of a silly hack and they’re working hard on a bunch of other cool stuff so we’ll let them off this one.

7. You’ll see one of two options:

— “There isn’t anything to compare” This means you’re up to date and you don’t have to do anything. Phew.

— A list of commits. These are the changes that have happened in the repository since you forked your version. Go to step 8.

8. Create a pull request.

Note that this pull request is to you! So you can confirm that it’s ok and merge it when necessary. And if there are any merge conflicts then it’s up to you to figure out what’s gone wrong and sort them out.

And now you’re ready to continue working on your fork👍

Well done!

Hansika Wanniarachchi

Written by

‘Learner who loves to code’

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade