【发布时间】:2017-07-04 23:28:15
【问题描述】:
我在 github 上找到了一个源代码。它有一些拉取请求,指示正在更改的代码。我想将其中一个下载/克隆到我的电脑上。它的 pull request id 是 3983,地址为https://github.com/BVLC/caffe/pull/3983 谢谢大家
【问题讨论】:
我在 github 上找到了一个源代码。它有一些拉取请求,指示正在更改的代码。我想将其中一个下载/克隆到我的电脑上。它的 pull request id 是 3983,地址为https://github.com/BVLC/caffe/pull/3983 谢谢大家
【问题讨论】:
因为有人有多个拉取请求,每个拉取请求都有自己的 ID。如何下载与拉取请求 ID 对应的正确版本
最好克隆原始repo,并导入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 到 origin:
git fetch origin pull/3983/head:pull_3983
git checkout pull_3983
您可以从该远程仓库获取其他 PR,或添加其他远程仓库以获取其他 PR。
【讨论】:
有两种方法可以做到这一点:
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'
【讨论】:
fatal: Not a git repository (or any of the parent directories): .git我需要先去caffe文件夹吗?
cd所以我加了cd caffe
https://github.com/christianpayer/caffe.git?
git checkout nd-cudnn 之后查看git log --oneline 并找到您感兴趣的提交哈希。你可以在 PR 中看到他正在合并的所有提交。