Git does not support downloading parts of the repository.
(Git不支持下载存储库的某些部分。)
You have to download all of it. (您必须全部下载。)
But you should be able to do this with GitHub. (但是您应该能够使用GitHub做到这一点。)
When you view a file it has a link to the "raw" version.
(当您查看文件时,它具有指向“原始”版本的链接。)
The URL is constructed like so (URL的结构如下)
https://raw.githubusercontent.com/user/repository/branch/filename
By filling in the blanks in the URL, you can use Wget or cURL (with the -L
option, see below) or whatever to download a single file.
(通过填写URL中的空格,您可以使用Wget或cURL (带有-L
选项,请参见下文)或下载单个文件的任何方法。)
Again, you won't get any of the nice version control features used by Git by doing this. (同样,这样做不会获得Git使用的任何出色的版本控制功能。)
Update: I noticed you mention this doesn't work for binary files.
(更新:我注意到您提到这不适用于二进制文件。)
You probably shouldn't use binary files in your Git repository, but GitHub has a download section for each repository that you can use to upload files. (您可能不应该在Git存储库中使用二进制文件,但是GitHub为每个存储库提供了一个下载部分,您可以使用该部分来上传文件。)
If you need more than one binary, you can use a .zip file. (如果需要多个二进制文件,则可以使用.zip文件。)
The URL to download an uploaded file is: (下载上载文件的URL为:)
https://github.com/downloads/user/repository/filename
Note that the URLs given above, from the links on github.com
, will redirect to raw.githubusercontent.com
.
(请注意,上面给出的URL(来自github.com
上的链接)将重定向到raw.githubusercontent.com
。)
You should not directly use the URL given by this HTTP 302 redirect because, per RFC 2616 : "Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests." (您不应该直接使用此HTTP 302重定向给出的URL,因为根据RFC 2616 :“由于重定向有时可能会更改,因此客户端应继续将Request-URI用于将来的请求。”)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…