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

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

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

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

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

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


当前回答

您可以复制GitHub文件的内容,然后将其粘贴到文件中。简单!

其他回答

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

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

请使用“{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()

为了跟进thomasfuchs所说的,但对于GitHub Enterprise用户,您可以使用以下内容。

curl-H'授权:令牌INSERTACCESSTOKENHERE'-H'接受:application/vnd.github.v3.raw'-O-Lhttps://your_domain/api/v3/repos/owner/repo/contents/path

这里还有API文档https://developer.github.com/v3/repos/contents

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

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