10

How can I apply pull request that was made for a parent repository of my fork into codebar of my fork. Not sure anyone can understand this question :), I'll try to explain with an an example.

There is a repo https://github.com/balupton/history.js, there are some pull request for this repo that has not been merged into the codebase, for example this one https://github.com/balupton/history.js/pull/251/commits. For some reason original developer do not accept it. Now, I have forked this repo https://github.com/prudnikov/history.js and want to merge this particular pull request into mu repository. How can I do this?

1
  • 1
    Github is actually designed to make this harder... because their revenue model is based on company accounts. If you upgrade to an organisation, you may find this easier.
    – user50953
    Commented Oct 24, 2013 at 12:30

1 Answer 1

7

You should be able to just pull down the other repo and have it merge with yours.

git pull {url-of-repo-with-commit-you-want-to-merge-in}

This will fetch the repo mentioned and have it automatically fast forward merge in any commits you don't have into yours.

So in your example, while on your master branch, or if you want to test it out on some other branch:

git pull git://github.com/dantipa/history.js.git
remote: Counting objects: 9, done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 5 (delta 4), reused 5 (delta 4)
Unpacking objects: 100% (5/5), done.
From git://github.com/dantipa/history.js
 * branch            HEAD       -> FETCH_HEAD
Updating e84ad00..e2d5251
Fast-forward
 scripts/uncompressed/history.js |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Now with the other commit merged with yours you can push back up to your own remote with that extra change.

4
  • But this will pull in whole branch with all commits that ahead current HEAD, right? Commented Feb 7, 2013 at 14:02
  • 2
    Oh, i've got an idea. I should create a new branch locally, pull down commits from other repo, then back to the master and cherry-pick desired commits. Commented Feb 7, 2013 at 14:05
  • Yes, working in a different branch you can cherry-pick from would be safer and allow more control Commented Feb 7, 2013 at 17:15
  • Be mindful if you actually cherry-pick commits from another forked repo as this might create confusion if you create your own pull request for the repo originally forked from.
    – Chris
    Commented Mar 7, 2013 at 4:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.