Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
739 views
in Technique[技术] by (71.8m points)

git - How do I download binary files of a GitHub release?

I have a repo with binary files in it that I need.

I can

git checkout tags/thetagoftherelease

which seems to checkout the correct tag, but does not pull down the binary files. How can I pull down the binary files that were added to the release (the green boxes on the release)?

Added picture of binary files in a release.

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I've tried for days trying to find the proper answer to this, and finally I figured out how to do this via the curl command. It's a 3-step process.

First, to get a list of the assets for the latest release:

curl -H "Authorization: token YOURGITHUBTOKEN" 
    https://api.github.com/repos/NAME/REPO/releases/latest 

Then in the JSON, look up the url of the asset you want. For example it would look like:

"url": "https://api.github.com/repos/NAME/REPO/releases/assets/1275759"

Then you pass this to another curl command to retrieve the actual URL, which is actually a link to an Amazon S3 file.

curl -H "Authorization: token YOURGITHUBTOKEN" 
     -H "Accept:application/octet-stream" 
     -i https://api.github.com/repos/NAME/REPO/releases/assets/1275759

The URL will be in the "location" field of the HTTP response, and then use curl to get the file like this:

curl "https://github-cloud.s3.amazonaws.com...." -i -o FILENAME

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...