How can I fetch an unmerged pull request for a branch I don't own?

后端 未结 13 1582
北荒
北荒 2020-11-27 10:55

I need to pull in a specific pull request (that hasn\'t been processed into the main stream yet) in the NServiceBus repo:

https://github.com/johnsimons/NServiceBus/c

13条回答
  •  悲&欢浪女
    2020-11-27 11:31

    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//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.

提交回复
热议问题