tags:

views:

899

answers:

1

I forked a GitHub repository. Then I pushed some changes to my fork. Then the original repository merged my changes and some others. Now, I want to merge those changes I'm missing. I tried a simple pull followed by push, but this yield my commits in duplicate. What's the best way to do it?

+15  A: 

You probably have a "remote" for each repository. You need to pull from the one remote and push to the other.

If you originally cloned from your fork, that remote will be called "origin". If you haven't added it already, you'll need to add the first guy's repository as another remote:

git remote add firstguy git://github.com/firstguy/repo.git

After that's all set up, you should indeed be able to

git pull firstguy master
git push origin

Remember, git pull is nothing more than a macro that does git fetch and git merge, in that order. You just need to fetch the list of commits from the first guy's repository and then merge his branch in to your tree. Merging should do the right thing with your commits on both branches.

GitHub, in all its perpetual awesomeness, gives you a shortcut, of course. There's a "fast-forward" button on your fork of the repository that you can use to catch your fork up if you're entirely merged in to the other side.

Jim Puls
Is there a way to do this entirely with remote operations? If I understand correctly, with this method you will download all the changes to the local repository and then upload (push) them all back to the fork on github. I'd rather just somehow pull all the changes directly into the fork on github.
Ken Liu