代码之家  ›  专栏  ›  技术社区  ›  teobais

如何(在分叉回购中)签出来自主回购的拉取请求?

  •  0
  • teobais  · 技术社区  · 7 年前

    据说我觉得项目A真的很酷,我把它放在了我的个人资料上。然后是项目A的分叉版本;让我们把它命名为项目B。


    然而,由于我已经有了项目B(它是项目A的分支),我想检查在项目A上打开的pull请求,在我的项目B上。

    来自项目B。


    到目前为止,我在网上找到的只是关于签出在项目a上打开的请求。

    2 回复  |  直到 7 年前
        1
  •  1
  •   cpanato    7 年前

    您需要在远程服务器中设置项目A并获取该项目,然后检查用户打开PR的分支

    比如说你的 git remote -v 是:

    origin https://github.com/toubou/projectA.git (fetch)
    origin https://github.com/toubou/projectA.git (push)
    

    $ git remote add upstream https://github.com/ORGINALREPO/projectA.git
    

    然后你的 git remote 将类似于:

    origin https://github.com/toubou/projectA.git (fetch)
    origin https://github.com/toubou/projectA.git (push)
    upstream https://github.com/ORGINALREPO/projectA.git (fetch)
    upstream https://github.com/ORGINALREPO/projectA.git (push)
    

    $ git fetch upstream
    

    然后检查分支,用户打开pr:

    $ git checkout branch_name
    
        2
  •  1
  •   teobais    7 年前

    @cpanato所提到的确实是正确的,但这只是第一步,因为问题是能够签出pull请求,而不是分支。

    需要将以下行添加到您的。git/config文件(上游部分):

    fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
    

    然后,您可以获取上游: git fetch upstream
    然后,您可以签出特定的拉请求,如下所示:

    git checkout origin/pr/11
    

    有关更多详细信息,您可以随时咨询 short article that I've written .