Here're the commands that worked for me.
I'll assume that one has already cloned a repo (for e.g. pytorch ) to his/her system locally. After that some volunteer/enthusiast has contributed some code and issued a PR to the remote repository but it has not been merged into the master or any other branch yet. So,
First we'll have to do git remote add
to the github remote repository:
# I've given the name `original`; you can give some other name as per your liking
$ git remote add original https://github.com/pytorch/pytorch
Then cd
into the repository pytorch
and then simply do:
# after this, the unmerged PR should be pulled to your local repo
$ git fetch original pull/<pull_number>/head # 23, 123 etc.,
Now, the pending PR has been fetched into your local repo and the tip of your fetch would be in FETCH_HEAD. If you want to merge this pending PR locally, then simply do:
$ git merge FETCH_HEAD
After this, if you do:
$ git status
You should be able to see that the local repo is ahead of n
commits that were part of the pending PR (i.e. it's possible to issue more than 1 commit in a single PR). So, the number of commits depend on the commits contained in the pending PR.