从GitHub repo下载单个文件有哪些技巧?

我不想要显示原始文件的URL;对于二进制文件,什么都没有。

http://support.github.com/discussions/feature-requests/41-download-single-file

是否有可能将GitHub用作“下载服务器”?

如果我们决定切换到GoogleCode,是否提供了上述功能?

或者开源项目是否有免费托管和VCS?


当前回答

只需将wget与raw=True参数一起使用

wget "https://github.com/user/repository/blob/master/directory/file_name?raw=True" -O target_path/file_name

其他回答

有一个名为Enhanced Github的chrome扩展

它将在每个文件的右侧直接添加一个下载按钮。

要从Github repo下载文件,请使用带有原始文件链接的“curl”命令。

curl https://raw.githubusercontent.com/user/repo/filename --output filename

添加--output选项,后跟新文件名,将原始文件下载到新创建的文件中。

这肯定会奏效的。至少在Chrome中。右键单击“原始”图标->将链接另存为。

转到脚本并单击“原始”

然后复制链接并使用aria2c链接下载。

例如:aria2chttps://raw.githubusercontent.com/kodamail/gscript/master/color.gsf

窍门:我想下载的文件是,https://github.com/kodamail/gscript*/blob*/master/color.gsf

只需将链接修改为https://raw.githubusercontent.com/kodamail/gscript/master/color.gsf

删除斜体文本并添加相同格式的粗体文本,这将为您提供正确的链接。

可以与aria2c、wget或curl一起使用,我在这里使用了aria2c。

现在,这在GitHub中可以用于任何文件。您需要翻译raw.github.com的文件。例如,如果您的文件位于存储库中:

https://github.com/<username>/<repo>/some_directory/file.rb

使用wget,您可以从以下位置获取原始文件:

https://raw.github.com/<username>/<repo>/<branch>/some_directory/file.rb

Rails Composer就是一个很好的例子。