My friends and family are under attack in Ukraine. Donate to protect them directly or help international organizations.

Sync git fork with maintainer

May 30th, 2011

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

Create and checkout "upstream/master" 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

Previous: Symfony task “default” context Next: SoundMixer + ByteArray