[英]can't download github project with curl command
我使用“curl -sO”命令从这个 GitHub 项目链接下载项目文件: http ://github.com/ziyaddin/xampp/archive/master.zip
但是,我无法下载。 出现错误并说:
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.
但我可以使用 curl 命令下载此链接: http : //cloud.github.com/downloads/pivotal/jasmine/jasmine-standalone-1.3.1.zip
我认为是因为它在 cloud.github.com 中。 我想知道如何使用 curl 命令从第一个链接下载?
curl -L -O https://github.com/ziyaddin/xampp/archive/master.zip
https://
-L
来跟踪重定向您还可以使用以下命令下载tarball
( *.tar.gz ):
curl -LkSs https://api.github.com/repos/ziyaddin/xampp/tarball -o master.tar.gz
或者如果你使用-O
你可以省略文件名,但是你保存的“.tar.gz”文件默认命名为“tarball”,所以你必须重命名它并添加“.tar.gz”文件类型后缀。 所以使用(小写) -o
如上所述。 其余的部分:
Ss
- 使用静默模式,但显示错误,如果有的话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
...所以如果您想遵循 HTTP 重定向,则需要使用-L
。 或者只是阅读史蒂文佩尼的回答......
curl -JLO "https://github.com/tada/pljava/archive/V1_6_2.zip"
-J, --remote-header-name 使用标头提供的文件名 (H)。
-L, --location 跟随重定向 (H)。
-O, --remote-name 将输出写入名为远程文件的文件。
要点参考
上述答案中没有提到的一件事是,如果您有一个非常大的文件,当您转到 GitHub 存储库中的该文件时,您会看到一条消息:
(Sorry about that, but we can’t show files that are this big right now.)
要下载这样的文件,需要向?raw=true
的 URL 添加一个参数,如以下curl
命令示例所示:
curl -L https://github.com/opengenpos/buildproducts/blob/main/GenPOS_rel_02_03_01_013.exe?raw=true >jkjk.exe
这会在 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>
并将该文件下载到名为jkjk.exe
的本地文件中。
(Windows 10 现在将tar
和curl
作为标准命令,现在看到Tar 和 Curl Come to Windows! ):
从 Insider Build 17063 开始,我们向 Windows 工具链引入了两个命令行工具:
curl
和bsdtar
。 已经很长时间了,我知道。 我们要bsdtar
创建和维护bsdtar
和curl
的人们——每天有数百万人使用这些很棒的开源工具。 让我们来看看这些工具将使在 Windows 上开发获得更好体验的两种有影响的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.