GitHub Api download zip or tarball link

You can wget your way out of the GitHub repo to get a tar file (archive):

wget --no-check-certificate

# better, if the certificate authorities are present:

will get you a file named ‘master’ from the user ‘User”s repo ‘repo’.

The updated V3 API url is:
# two possibilities for fomat:

# from github example:
$curl -L > octokit.tar.gz

You can then tar xpvf master, getting the full archive. It will create a directory following the naming convention described in the question you mentioned.

No Git binary is needed to get an archive from GitHub, thanks to their download service “Nodeload”.

ligemer proposed in an edit the following example:

Edit 2016-08-25 – Shell Example With Wget, Variables, and Untar:

#!/bin/bash -ex

# arguments:
# token = $1
# organization = $2
# repo name = $3
# branch = $4

wget --header="Authorization: token ${1}" --header="Accept:application/vnd.github.v3.raw" -O -${2}/${3}/tarball/${4} | tar xz

Call via:

$ token my-organization site.example master

The command above will download and extract the GitHub folder to the same directory as the script.

Diogo Quintela suggests in the comments:

The following example allow the download, extract and cut the top level directory

curl -L | tar xz --strip=1

Leave a Comment