2013-10-14 100 views
5

我试图下载Github受保护的repo中的项目的安装脚本。如何仅从Github受保护的存储库获取文件

userrepo被替换为正确的信息。

我已经试过卷曲:

curl -u gabipetrovay -L -o install.sh "https://raw.github.com/user/repo/master/admin/scripts/install.sh" 

卷曲提示输入密码,但只要我输入第一个字符它更进一步,下载的东西(很多JS可能从GitHub)

我也试过wget的:

wget --user=gabipetrovay --ask-password "https://raw.github.com/user/repo/master/admin/scripts/install.sh" 

随着wget的,我可以进入我的完整密码,但后来我得到一个503错误:

Resolving raw.github.com (raw.github.com)... 199.27.73.133 
Connecting to raw.github.com (raw.github.com)|199.27.73.133|:443... connected. 
HTTP request sent, awaiting response... 503 Connection timed out 
2013-10-14 10:18:45 ERROR 503: Connection timed out. 

如何获取install.sh文件?

+1

可能重复://计算器.com/questions/18126559/how-can-i-download-a-single-raw-file-from-a-private-github-repo-using-the-comman) –

回答

0

您需要创建一个OAuth令牌解释有(我从一个Ubuntu服务器13.04运行此):Github basic authentication

那么你可以使用下面的命令,袅袅得到暂时的网址,所以你需要使用“ -L”在卷曲跟随重定向:

curl -L -u <your token>:x-oauth-basic https://raw.github.com/user/repo/master/admin/scripts/install.sh 

您还可以使用-o‘文件名’将其保存在磁盘上

+0

我试过这个,但这不起作用。你会得到一个503错误(即使有重定向) –

5

而且从GitHub的家伙的官方回应是:

Thanks for getting in touch! For this case, you'll want to use our API to download individual files:

http://developer.github.com/v3/repos/contents/#get-contents

With this endpoint, you can get a specific file like this:

curl -u gabipetrovay -H "Accept: application/vnd.github.raw" "https://api.github.com/repos/user/repo/contents/filename" 

You'll just be prompted for your GitHub account password in this case, or you can also use an OAuth token as well. For reference, our API Getting Started Guide has a nice section on authentication:

http://developer.github.com/guides/getting-started/#authentication

而且这个作品很有魅力!

感谢罗伯特@ Github上

2

您可以使用V3 API来得到这样一个原始文件(你需要一个OAuth令牌):

curl -H 'Authorization: token INSERTACCESSTOKENHERE' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/owner/repo/contents/path

所有这一切都必须去在一条线上。 -O选项将文件保存在当前目录中。您可以使用-o filename来指定不同的文件名。

为了得到OAuth令牌按照下列指示: https://help.github.com/articles/creating-an-access-token-for-command-line-use

这允许更好的自动化如果,比如说,需要从一个shell脚本做到这一点。

我写这件事的要点,以及: https://gist.github.com/madrobby/9476733

[我如何可以从使用命令行的私人github上回购单个原始文件?(HTTP的
相关问题