如何从拉取请求克隆/下载代码

时间:2017-02-16 02:59:40

标签: git github

我在github中找到了一个源代码。它有一些拉动请求,表示更改的代码。我想将其中一个下载/克隆到我的电脑上。其拉取请求ID在地址https://github.com/BVLC/caffe/pull/3983处为3983 谢谢所有

2 个答案:

答案 0 :(得分:4)

  

因为有人有更多的拉取请求,每个拉取请求都有自己的ID。如何下载与拉取请求ID

对应的正确版本

最好克隆原始仓库,然后导入PR branch based on its ID

git clone https://github.com/BVLC/caffe
cd caffe
git remote add christianpayer https://github.com/christianpayer/caffe.git

然后,对于Christianpayer的一个合并PR来源:

git fetch origin pull/3983/head:pull_3983
git checkout pull_3983

您可以从该远程仓库获取其他PR,或添加其他远程仓库以获取其他PR。

答案 1 :(得分:1)

有两种方法可以做到这一点:

<强> 1

git clone https://github.com/christianpayer/caffe.git
cd caffe
git checkout nd-cudnn

来自这里:

https://github.com/christianpayer/caffe/tree/nd-cudnn

<强> 2

git clone https://github.com/BVLC/caffe.git

cd caffe/.git

现在将行fetch = +refs/pull/*/head:refs/remotes/origin/pr/*添加到config

[remote "origin"]
        url = https://github.com/BVLC/caffe.git
        fetch = +refs/heads/*:refs/remotes/origin/*
        fetch = +refs/pull/*/head:refs/remotes/origin/pr/*

现在获取所有拉取请求:

$ git fetch origin
From github.com:joyent/node
 * [new ref]         refs/pull/5190/head -> origin/pr/5190
 * [new ref]         refs/pull/5193/head -> origin/pr/5193
 * [new ref]         refs/pull/5198/head -> origin/pr/5198
 * [new ref]         refs/pull/520/head -> origin/pr/520

...

检查特定的提款请求:

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