git 下载 github 项目的特定分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32340337/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Download a specific branch of a github project
提问by Ali Shakiba
To cut the story short, to run a convolutional neural network model, I need an special version of nolearn
, which has a url of the form https://github.com/dnouri/nolearn/tree/1659e4811e498dc1f442d8e6486d0831f85255b4/nolearn. However, there are no Download as Zip
buttons at the page, nor I can download it with
简而言之,要运行卷积神经网络模型,我需要一个特殊版本的nolearn
,其网址格式为https://github.com/dnouri/nolearn/tree/1659e4811e498dc1f442d8e6486d0831f85255b4/nolearn。但是,Download as Zip
页面上没有按钮,我也无法下载
git clone https://github.com/dnouri/nolearn -branch 1659e4811e498dc1f442d8e6486d0831f85255b4/nolearn
Simply,
简单地,
git clone https://github.com/dnouri/nolearn/tree/1659e4811e498dc1f442d8e6486d0831f85255b4/nolearn
does not work, too.
也不行。
Even, I have no idea what should I search for in Google!
甚至,我不知道我应该在谷歌搜索什么!
Note: This is the last version which provided support for the class Objective
, i.e. the command from lasagne.objectives import Objective
is no more supported!
注意:这是对 class 提供支持的最后一个版本Objective
,即from lasagne.objectives import Objective
不再支持该命令!
回答by mayo
This can help you:
这可以帮助您:
How to clone a single branch in git?
Where specifies:
其中指定:
git clone <url> --branch <branch> --single-branch [<folder>]
Docu :
文件:
--[no-]single-branch
Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote's HEAD points at. When creating a shallow clone with the --depth option, this is the default, unless --no-single-branch is given to fetch the histories near the tips of all branches. Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If the HEAD at the remote did not point at any branch when --single-branch clone was made, no remote-tracking branch is created.
--[no-]单分支
仅克隆导致单个分支尖端的历史记录,由 --branch 选项指定或主分支远程的 HEAD 指向。使用 --depth 选项创建浅层克隆时,这是默认设置,除非给出 --no-single-branch 以获取所有分支尖端附近的历史记录。进一步获取结果存储库将仅更新此选项用于初始克隆的分支的远程跟踪分支。如果在进行 --single-branch 克隆时远程的 HEAD 没有指向任何分支,则不会创建远程跟踪分支。
回答by das-g
Other than in Subversion (SVN), git has separate namespaces for directories (file system folders), branches and tags. Thus https://github.com/dnouri/nolearn/tree/1659e4811e498dc1f442d8e6486d0831f85255b4/nolearnis not, per se, a branch. 1659e4811e498dc1f442d8e6486d0831f85255b4
is a commit ID, used here to refer to the revision created by the commit. dnouri/nolearn
is the repository name on GitHub (repository nolearn
on account dnouri
) and the final nolearn
in the URL is a directory within the content of revision 1659e4811e498dc1f442d8e6486d0831f85255b4
.
除了在 Subversion (SVN) 中,git 具有用于目录(文件系统文件夹)、分支和标签的单独命名空间。因此,https://github.com/dnouri/nolearn/tree/1659e4811e498dc1f442d8e6486d0831f85255b4/nolearn本身并不是一个分支。1659e4811e498dc1f442d8e6486d0831f85255b4
是一个提交 ID,这里用来指由提交创建的修订。dnouri/nolearn
是 GitHub 上的存储库名称(nolearn
帐户上的存储库dnouri
),nolearn
URL 中的最后一个是修订内容中的目录1659e4811e498dc1f442d8e6486d0831f85255b4
。
The 'normal' way to get this code with git would be:
使用 git 获取此代码的“正常”方法是:
replicate the repository to your local machine
git clone https://github.com/dnouri/nolearn.git
(You can find this URL on the repository's page https://github.com/dnouri/nolearn, in the 'clone URL' field.)
enter the local repository
cd nolearn
check out the wanted revision
git checkout 1659e4811e498dc1f442d8e6486d0831f85255b4
change into the respective directory inside the repository
cd nolearn
将存储库复制到本地计算机
git clone https://github.com/dnouri/nolearn.git
(您可以在存储库页面https://github.com/dnouri/nolearn的“克隆 URL”字段中找到此 URL 。)
进入本地仓库
cd nolearn
查看想要的修订版
git checkout 1659e4811e498dc1f442d8e6486d0831f85255b4
切换到存储库中的相应目录
cd nolearn
回答by landareex
This is the link to the .zip : https://github.com/dnouri/nolearn/archive/1659e4811e498dc1f442d8e6486d0831f85255b4.zip
这是 .zip 的链接:https: //github.com/dnouri/nolearn/archive/1659e4811e498dc1f442d8e6486d0831f85255b4.zip