Update a Github Fork From the Original Repository

January 12, 2012

While it is easy to create forks of other projects through Github, it isn't as easy to update your fork from the parent repository. The following steps are what I do to update my fork. These steps assume that you have a local copy of the repository and that everything is up to date and committed.

First you need to add a remote to the repository you forked.

$ git remote add --track <branchname> <projectname> git://github.com/<gitmember>/<project>.git

Where,

To see that the remote was successfully added you can run

$ git remote -v

which will show all the remotes your local repository currently has.

Next you want to fetch all the changes from the newly added remote.

$ git fetch <projectname>

Where projectname is the name you assigned to the remote above.

This fetch operation will create a new branch in your repository called projectname/branchname. With that in place you are ready to merge.

$ git merge projectname/branchname

That's all there is to updating your fork from the parent repository.

Author's profile picture

Mark H. Nichols

I am a husband, cellist, code prole, nerd, technologist, and all around good guy living and working in fly-over country. You should follow me on Twitter.