Github tarball download


Github provides a feature of downloading entire repository from a single URL (a tarball). The downloaded repository file is combined into a single file using Linux tar command. The archive file is also compressed using gzip compression.

The tarball URL is as follows:

https://github.com/<username>/<repository>/tarball/<version>

Where username is Github username, repository is a Github repository name and version can be either a git repository branch name or a tag name.

The repository tarball file can be downloaded using one of the popular tools like wget or curl. Let’s try to get Flake Id generator: https://github.com/T-PWK/flake-idgen

The file will contain a repository directory with name convention as follows:

<username>-<repository>-<abbreviated-SHA-1-checksum>

Where username is a Github username, repository is a Github repository name and abbreviated-SHA-1-checksum is the latest commit in a specified branch or the specified tag commit abbreviated SHA-1 checksum.

Example: https://github.com/T-PWK/flake-idgen/tarball/v0.1.4 will contain a repository for tag v0.1.4, and the directory will be called T-PWK-flake-idgen-9273402.

wget

To download the master version of the repository, use the following command.

wget https://github.com/T-PWK/flake-idgen/tarball/master

If you want to extract repository directory bypassing file download, you can use -O - option (to have the file written to standard output) and pipe the output to tar xz command.

wget -O - https://github.com/T-PWK/flake-idgen/tarball/master | tar xz

curl

Curl is very similar to wget in respect of a tarball file download. However, -L follow HTTP(S) redirects option must be used (wget follows HTTP(S) redirects by default) as the tarball files are served by slightly different URL.

curl -L https://github.com/T-PWK/flake-idgen/tarball/master > master

Alternatively, you can extract the repository directory straight from the input stream

curl -L https://github.com/T-PWK/flake-idgen/tarball/master | tar xz

Tags:

#curl#github#wget


You may also be interested in: