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

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

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

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

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

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


当前回答

2021,GitHub增加了一项新功能,即在web上打开visual studio代码。只需按句号或周期键即可启动。,当您在任何存储库中时。

因此,要下载任何特定文件,您可以按启动vscode。键,然后它将在vscode中显示存储库的所有文件。在那里,您可以通过右键单击>dowload下载所需的任何文件。

其他回答

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

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

我认为新的url结构是raw.giturl,例如:

git文件

raw

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

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

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

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

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

为了跟进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

您应该只使用文件的原始URL进行操作。

例如,下载AFNetworking的README:

curl https://raw.githubusercontent.com/AFNetworking/AFNetworking/master/README.md > ADREADME.md 

由于它是公共回购,因此您不需要任何凭据。请注意url的类型:raw.githubusercontent.com/path/to/file