Update a Github Fork from the Original Repo

Feather Blog has made some great progress recently and when looking to update my fork I found myself staring at my repo not sure what to do. My wonderful Github didn’t give me a one-click way to pull updates from the original repository (or any other fork for that matter). I’ll demonstrate how to do this with my fork of Feather. I’ll assume you already have a locally copy of a repo with everything committed and up-to-date.

First you need to add a remote branch to your repository that points to the original repo you forked from.

git remote add --track master mleung git://github.com/mleung/feather.git

You will want to replace ‘master’ with the branch you want to track in the remote repo. In most cases this will be master, although you could replace it with edge or any other branch. You should also replace ‘mleung’ is what you the remote will be called.

To verify the remote repository was added run

git remote

You should see the new remote repo, in this case named ‘mleung’, along with any other remote repositories you may have previously added.

Now we can fetch all the changes from mleung’s code base.

git fetch mleung

This will create a new remote branch called ‘mleung/master’. Now we are ready to merge the code from the remote repository.

git merge mleung/master

That’s it. Remember, this process isn’t limited only to the original repository. Feel free to add remote branches for other user’s forks or even from repositories outside Github.

8 Comments

  1. ves
    Posted January 25, 2009 at 2:07 am | Permalink

    Cheers for this. Git newb myself and this wasn’t that obvious :)

  2. Posted March 10, 2009 at 1:45 pm | Permalink

    Thanks for this. I just wanted to add, that instead of doing `git fetch mleung` then `git merge mleung/master`, you can do it in one step with `git pull mleung master`.

    Before your post I was doing it the old fashioned way, e.g. `git pull git://github.com/mleung/feather.git master`. You just saved me a bunch keystrokes!

  3. Posted May 2, 2009 at 9:51 am | Permalink

    Thumbs up!
    Thanks

  4. Posted May 7, 2009 at 6:59 pm | Permalink

    Thanks for the info. I just started using git this week and your post helped out a lot!

  5. Alfredo
    Posted May 10, 2009 at 11:36 am | Permalink

    Wow buddy, thats precisely what I was looking for. Thank u very much for the info!!

  6. Posted October 25, 2009 at 2:51 pm | Permalink

    I get “fatal: Not a git repository (or any of the parent directories): .git” when I try to run “git remote add –track master mleung git://github.com/mleung/feather.git”. Why?

  7. Posted November 11, 2009 at 10:02 pm | Permalink

    @Erik Nord – I think you need to change your CWD to the git repo that you want to add the remote repo to – that error usually indicates that you aren’t (locally) in a git repository.

  8. Posted July 5, 2010 at 10:08 pm | Permalink

    Thanks for the tip, worked great

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*