Rebase from forked repo

Fra Gadaleta
Jul 22, 2020

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 https://github.com/author/cool-project.git and the forked repo will be at https://github.com/myself/cool-project.git

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 https://codingossip.github.io on July 22, 2020.

--

--

Fra Gadaleta

🏢 Founder of Amethix 🌟 Building software wizardry and 🦀 Rust-powered wonders 🎧 Host of the mind-bending podcast https://datascienceathome.com