Rebase from forked repo

It is very common to fork a repo you are interested in and start reading code and learn how things are done. Then after a few days realizing that the forked repo is already behind upstream and need to resync. Here is a standard way of doing just this safely.

We will call the main project to fork and the forked repo will be at

From the forked repo we need to add the remote upstream (the original repo we have forked from)

Then we need to fetch all branches with

Let’s move to master branch on the forked repo

and finally rebase. This means that all commits that are not yet in upstream (and usually they never are) will be applied on top of the other branch

Easy. Happy coding!

Originally published at on July 22, 2020.



Managing Director @ Chief Software Engineer & Host

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store