2013-10-14 139 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的
相關問題