简体   繁体   English

无法使用 curl 命令下载 github 项目

[英]can't download github project with curl command

I used "curl -sO" command to download project files from this GitHub project link: http://github.com/ziyaddin/xampp/archive/master.zip我使用“curl -sO”命令从这个 GitHub 项目链接下载项目文件: http ://github.com/ziyaddin/xampp/archive/master.zip

but, I couldn't download.但是,我无法下载。 There is error occured and says that:出现错误并说:

Archive:  /home/ziyaddin/Desktop/master.zip
[/home/ziyaddin/Desktop/master.zip]   End-of-central-directory
signature not found.  Either this file is not   a zipfile, or it
constitutes one disk of a multi-part archive.  In the   latter case
the central directory and zipfile comment will be found on   the last
disk(s) of this archive. zipinfo:  cannot find zipfile directory in
one of /home/ziyaddin/Desktop/master.zip or
          /home/ziyaddin/Desktop/master.zip.zip, and cannot find 
/home/ziyaddin/Desktop/master.zip.ZIP, period.

but I can download this link with curl command: http://cloud.github.com/downloads/pivotal/jasmine/jasmine-standalone-1.3.1.zip但我可以使用 curl 命令下载此链接: http : //cloud.github.com/downloads/pivotal/jasmine/jasmine-standalone-1.3.1.zip

I think that it is because it is in cloud.github.com.我认为是因为它在 cloud.github.com 中。 I want to know how can I download from first link with curl command?我想知道如何使用 curl 命令从第一个链接下载?

curl -L -O https://github.com/ziyaddin/xampp/archive/master.zip
  • you must use https://您必须使用https://
  • you must use -L to follow redirects您必须使用-L来跟踪重定向

You can also download a tarball ( *.tar.gz ) with:您还可以使用以下命令下载tarball ( *.tar.gz ):

curl -LkSs https://api.github.com/repos/ziyaddin/xampp/tarball -o master.tar.gz

or if you use the -O you can omit the filename, but then your saved ".tar.gz" file, is named by default to "tarball", so you have to rename it and add the ".tar.gz" filetype postfix.或者如果你使用-O你可以省略文件名,但是你保存的“.tar.gz”文件默认命名为“tarball”,所以你必须重命名它并添加“.tar.gz”文件类型后缀。 So use the (lowercase) -o as above.所以使用(小写) -o如上所述。 The rest:其余的部分:

  • Ss - use silent mode, but show errors, if any Ss - 使用静默模式,但显示错误,如果有的话
  • k - use an insecure SSL connection without checking the TLS cert. k - 使用不安全的SSL 连接而不检查 TLS 证书。
$ curl -I http://github.com/ziyaddin/xampp/archive/master.zip
HTTP/1.1 301 Moved Permanently
Server: GitHub.com
Date: Sun, 28 Apr 2013 09:24:53 GMT
Content-Type: text/html
Content-Length: 178
Connection: close
Location: https://github.com/ziyaddin/xampp/archive/master.zip
Vary: Accept-Encoding

... so you need to use -L if you want to follow the HTTP redirect. ...所以如果您想遵循 HTTP 重定向,则需要使用-L Or just read Steven Penny's answer...或者只是阅读史蒂文佩尼的回答......

curl -JLO "https://github.com/tada/pljava/archive/V1_6_2.zip"

-J, --remote-header-name Use the header-provided filename (H). -J, --remote-header-name 使用标头提供的文件名 (H)。
-L, --location Follow redirects (H). -L, --location 跟随重定向 (H)。
-O, --remote-name Write output to a file named as the remote file. -O, --remote-name 将输出写入名为远程文件的文件。

Gist Reference要点参考

One thing not mentioned in the above answers is what if you have a really large file such that when you go to that file in a GitHub repository, you see a message that says:上述答案中没有提到的一件事是,如果您有一个非常大的文件,当您转到 GitHub 存储库中的该文件时,您会看到一条消息:

(Sorry about that, but we can’t show files that are this big right now.)

来自 GitHub 的注释屏幕截图,该文件太大而无法显示

To download such a file requires adding an argument to the URL of ?raw=true as in the following curl command example:要下载这样的文件,需要向?raw=true的 URL 添加一个参数,如以下curl命令示例所示:

curl -L https://github.com/opengenpos/buildproducts/blob/main/GenPOS_rel_02_03_01_013.exe?raw=true >jkjk.exe

This results in the following output in a Windows command shell window:这会在 Windows 命令外壳窗口中产生以下输出:

C:\Users\rickc\Documents>curl -L https://github.com/opengenpos/buildproducts/blob/main/GenPOS_rel_02_03_01_013.exe?raw=true >jkjk.exe
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   146  100   146    0     0    146      0  0:00:01 --:--:--  0:00:01   491
100   157  100   157    0     0    157      0  0:00:01 --:--:--  0:00:01  153k
100 15.7M  100 15.7M    0     0  15.7M      0  0:00:01  0:00:01 --:--:-- 12.7M

C:\Users\rickc\Documents>

and the file is downloaded to a local file named jkjk.exe .并将该文件下载到名为jkjk.exe的本地文件中。

(Windows 10 now has both tar and curl as standard commands now see Tar and Curl Come to Windows! ): (Windows 10 现在将tarcurl作为标准命令,现在看到Tar 和 Curl Come to Windows! ):

Beginning in Insider Build 17063, we're introducing two command-line tools to the Windows toolchain: curl and bsdtar .从 Insider Build 17063 开始,我们向 Windows 工具链引入了两个命令行工具: curlbsdtar It's been a long time coming, I know.已经很长时间了,我知道。 We'd like to give credit to the folks who've created and maintain bsdtar and curl — awesome open-source tools used by millions of humans every day.我们要bsdtar创建和维护bsdtarcurl的人们——每天有数百万人使用这些很棒的开源工具。 Let's take a look at two impactful ways these tools will make developing on Windows an even better experience.让我们来看看这些工具将使在 Windows 上开发获得更好体验的两种有影响的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM