George George - 4 months ago 23
Git Question

Download repo as a zip file

I am trying to download as a zip file a private GitHub repo.

I am trying:

curl -H "Authorization: token f19..." -L https://github.com/Mylab/name/archive/release.zip


and it shows me:

{"error":"Not found"}


If I try:

curl -H "Authorization: token f19..." -L -o release.zip https://github.com/Mylab/name/archive/release.zip


it downloads a very small zip file which I can't open because it says "Either this file is not zip ......".

Answer

This should solve your problem

curl -H "Authorization: token f19..." -Lk https://api.github.com/repos/Mylab/name/zipball/release -o release.zip 

EDIT : you need to customize :

  • Mylab : user or organization
  • name : repository name
  • release : tag or branch targeted

EDIT 2: you need to have a token that have the whole "repo" category ticked to grant you full access to private repositories

EDIT 3: beware there must be only one space between token and f19...

Comments