Introduction
I have a couple of forked git repositories. When I want to add custom code it’s useful to get the latest available code from the “original” repository. Before I can do that I have to sync my fork with the latest available code.
The steps to do this are explained extensively in the Github help, this is merely a placeholder for my own documentation.
Some online resources
- https://help.github.com/articles/syncing-a-fork/
- https://help.github.com/articles/configuring-a-remote-for-a-fork/
Configuring a remote for a fork
The first step that you will have to take is to add the remote repository as an ‘upstream’ repository.
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
Check that it has been added with
git remote -v
Sync the fork
Once the remote authoritative repository has been added as upstream you’ll have to sync from the upstream code.
git fetch upstream git checkout master git merge upstream/master
Once this is done you can update your local repository with Github and you’ll have an updated version.