How to download a tarball from GitHub in shell script

I know I can use git clone to fetch a repository. Is there easy way to get entire repo as a tarball in shell script?
Instead of the following

git clone

I want


Not working. Hence, asking how can I download it as a tarball from GitHub?

Downloading a tarball or zip file from GitHub is easy. We can either use the curl or wget command.

Turn git url to zip or tar url

echo ${out}.{zip,tar.gz}
echo "TARBALL: $outtar"
echo "ZIP: $outzip"

Using wget to download a tarball or zip file from GitHub

Use the wget

wget "$outtar"
wget "$outzip"

And the curl:

# The '-L' allow curl to follow redirects
# The '-O' allow to save and write output to a local file named like the remote file we get
curl -L -O "$outtar"
curl -L -O "$outzip"

# How to verify downloaded files from Github?
ls master*
file master*

And we have files:

master.tar.gz: gzip compressed data, from Unix, original size modulo 2^32 901120    Zip archive data, at least v1.0 to extract
1 Like

Worked on my shell script <3

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki