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

后端 未结 13 1537
北荒
北荒 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

    Once you added the upstream repo as an upstream remote (as @elias pointed out):

    $ git remote add upstream git@github.com:Particular/NServiceBus
    

    You can configure git to fetch pull requests by default:

    $ git config --local --add remote.upstream.fetch '+refs/pull/*/head:refs/remotes/upstream/pr/*'
    

    So, let's fetch it:

    $ git fetch upstream
    Fetching upstream
    remote: Counting objects: 4, done.
    remote: Compressing objects: 100% (2/2), done.
    remote: Total 4 (delta 2), reused 4 (delta 2), pack-reused 0
    Unpacking objects: 100% (4/4), done.
    From https://github.com/Particular/NServiceBus
     * [new ref]         refs/pull/1/head -> upstream/pr/1
     * [new ref]         refs/pull/2/head -> upstream/pr/2
    

    And check it out:

    $ git checkout pr/2
    Branch pr/2 set up to track remote branch pr/2 from upstream.
    Switched to a new branch 'pr/2'
    

提交回复
热议问题