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

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

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

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

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

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


当前回答

请使用“{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文件进行测试(在回答时)

对于使用GitHub Enterprise的用户,您需要按照以下方案构造URL

调用WebRequesthttp://github.mycompany.com/api/v3/repos/my-org/my-repo/contents/myfiles/file.txt-标头@{“Authorization”=“token 8d795936d2c1b2806587719b9b6456bd16549ad8”}

详细信息可在此处找到

http://artisticcheese.blogspot.com/2017/04/how-to-download-individual-files-from.html

我使用了以下格式,我觉得告知路径很重要。

https://github.com/user/repository/raw/branch/filename

^^^以上内容在我看来并不完整

https://github.com/<user>/<repoROOTname>/blob/master/<path>/<filename>?raw=true

有些人说raw.github.com或raw而不是blob,但第二行对我有用,我希望能帮助其他人。。。

您链接到的页面回答了第一个问题。GitHub还提供了一个下载工具,用于发布等内容。谷歌代码根本没有Git。GitHub、Google Code和SourceForge是免费托管。SourceForge可能仍然会做CVS。

在“桌面中的克隆”的右侧,它显示“下载Zip文件”下载Zip文件提取文件