PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Sync git fork with maintainer

Note: This article was originally published at Planet PHP on 31 May 2011.
Planet PHP

I forked the joind.in project on GitHub, committed a few patches and sent pull requests. It was fun until I asked myself aohow do I keep my fork synced with the maintainer's repo?a I found the info (with minor bug) on Google Groups by Matt Todd. It deserved its own post post.

Create and checkout aoupstream/mastera branch (or whatever you want to call it):

git checkout -b upstream/master

Link branch to maintainer's repo:

git remote add upstream git://github.com/upstream_maintainer/master.git

Pull maintainer's repo:

git pull upstream master

Switch to your fork's master branch:

git checkout master

Merge maintainer's repo into your fork:

git merge upstream/master

Subsequent syncs

The next time you want to sync, you only need to switch branches, pull and merge:

git checkout upstream/master git pull upstream master git checkout master git merge upstream/master