Keep your forks updated

Tue, Jan 15, 2019 1-minute read

You are looking to contribute to an awesome project on GitHub and you finally find it and fork the repo. a few weeks later you worked on the forked repo but are afraid the fork is way behind the original repo. how would you keep it up to date? here is how

fork

Photo by Clément H on Unsplash


1.Add the remote/original repo and lets call it upstream

git remote add upstream https://github.com/original-repo/repo-name.git

2.Fetch all branches from remote upstream

git fetch upstream

3.Use git rebase to re-write your master with upstream’s master.

git rebase upstream/master

Note: rebase will fail, if you have uncommitted changes in your forked master

4.Push your updates to master using force

git push origin master --force