This is from my stackoverflow question. Thanks to “bitoiu”. Here is the real thread.
How to pick up a single commit from a remote repo
Assuming you have a local clone of the repo you forked if you type in the following you should get a single origin:
> git show remote origin
Unless you’ve added the original’s repo location, you won’t have access to the commit you want to pick into your local one. So we need to add that, let’s assume this repo ishttps://github.com/GitbookIO/gitbook.git. Notice this is an HTTPS clone URL because you won’t have write access to this repo. Let’s name it original_repo:
> git remote add original_repo https://github.com/GitbookIO/gitbook.git
And now let’s get all the refs back:
> git fetch origina_repo
At this point you have all you need locally, you’ll just need to merge the commit into one of your branches, let’s assume your local master.
Find the commit you want to merge. This implies finding it in one of the branches the team used. Could be already merged to master or you could be picking it up from the branch that was used for the pull request. Either way, just run a series of
git log to check what commit you want if you don’t know the reference. When you do simply go to the branch where you want to merge the commit to and run:
> git cherry-pick COMMIT_ID
This will bring the commit to whatever branch you are at the moment.
How to merge a branch from a remote repo
The only difference in this steps is that instead of doing the cherry-pick you will be doing a merge. So imagine the contents of the pull request are in a branch named
so-pr, you would simply do:
> git merge original_repo/so-pr
And that would merge the contents of
so-pr into your working branch.