Syncing a Fork

At work, we work with an agency who provides website development services. They own and maintain the repository on github and we only have read access to it. So in order for us to make changes, we have to fork the repository, make changes, and send pull requests.

However, because developers at the agency work on the site everyday, our forks are not always up-to-date with the original repository. Then when we need to make changes, we have to make sure that we have the latest changes in our forked projects before sending pull requests. So here is a set of commands you can run to make your forked repo up-to-date with the original repo.

First, fetch all branches and commits from the upstream (original) repository.

git fetch upstream

Check out your fork’s local master

git checkout master

Then merge the changes from upstream to your local master

git merge upstream/master

At this point, you have all the latest changes from original repo on your local machine. Next we sync up the changes from your local machine to your fork.

git push REMOTE_NAME BRANCH_NAME

That’s it!

Published by Seong Bae

I am a web developer and digital marketing professional from Northern Virginia. I'm passionate about anything & everything about the web and the web technologies that empower us to do great things. bae.seong at gmail.com Linkedin Github