How to download a GitHub repo as .zip using command line

From the comments I saw you actually speak about GitHub.

It won't work like this because:

Downloading a project on GitHub causes the GitHub server to first pack your project as zip and than forwarding you to a temporary link where you get your zip ..

this link will only work for a certain time and than GitHub will delete your zip file from their servers..

So what you get with wget is just the html page which would forward you as soon as your zip file is generated.

As suggested use

git clone http://github.com/<yourRepoLink> <optional local path where to store>

to download the git repo ... If for some reason (e.g. for transfer it to others) you need it explicitly as zip you still could pack it after cloning is finished..


It does work, if you use the correct URL.

For a GitHub repo, there's a zip at https://github.com/<user>/<repo>/archive/<branch>.zip, so you can download it with:

wget https://github.com/<user>/<repo>/archive/<branch>.zip

This downloads the zipped repo for a given branch. Note that you can also replace the branch by a commit hash.

Using cURL

curl -L https://github.com/<user>/<repo>/archive/<branch>.zip

cURL's -L flag follows redirects - it's a default in wget.

Download a .tgz instead of .zip

You can also download a tarball with:

wget https://github.com/<user>/<repo>/archive/<branch>.tar.gz