Merging in a GitHub fork

I’m working on a new project in GitHub called Bixo, and recently had to merge in a fork from Chris Wensel. After poking around on the web a bit, I found some very useful information in Willem’s blog post on Remote branches in git.

There was one minor error, though, in the “Merging back a fork” section. After the “git remote add…” command, you have to do a “git fetch <remote>” command to first fetch the remote branches before you can successfully do a “git branch <branch name> <remote/branch>” command.

So in my case, this meant:

% cd git/github/bixo
% git remote add chris git://
% git fetch chris
% git branch chris-fork chris/master

And once that worked, I could merge from his branch to mine, and push back the changes.

Slowly but surely the git model accretes in my head.

4 Responses to Merging in a GitHub fork

  1. Ryan says:

    Thanks Ken — needed to figure out how to merge my fork, worked like a charm 🙂

  2. Sorcix says:

    You didn’t have to branch it first. You could simply do

    % cd git/github/bixo
    % git remote add chris git://
    % git merge chris/master

    • kkrugler says:

      Hi Sorcix,

      You’re right, and Willem also updated notes on his page about this shortcut. He includes info how to switch to the remote branch for testing, which is handy. Specifically:

      % git remote add chris git://
      % git fetch chris
      % git checkout chris/master

      Now test Chris’s modifications

      % git checkout master
      % git merge chris/master

  3. Dave Coleman says:

    Thanks, worked great!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: