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

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

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

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

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

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


当前回答

GitHub Mate可以轻松下载单个文件,只需单击图标即可下载,目前它只能在Chrome上运行。

其他回答

现在,这在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就是一个很好的例子。

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

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

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

若您使用npm,只需运行以下命令行,最后,除了这个github文件,它不会下载任何npm包

npx config-pack https://github.com/facebook/react/blob/main/README.md

有关详细信息,请参阅配置包

请使用“{host}/{user}/}repo}/branch}/{file}”的模式。要获得具体示例,请在Python中执行以下操作:

import pandas as pd
host = 'raw.github.com'
user = 'fivethirtyeight'
repo = 'data'
branch = 'master'
file = 'births/US_births_2000-2014_SSA.csv'
url = f'https://{host}/{user}/{repo}/{branch}/{file}'
df = pd.read_csv(url,sep=',',header=0)
df.head()

这就是我刚才所做的。。。

在单独的选项卡中打开原始文件。将整个内容复制到记事本中的新文件中。将文件保存为原来的扩展名

使用我刚才下载的php文件进行测试(在回答时)