How do I download a tarball from GitHub using cURL?

saltycrane picture saltycrane · Apr 21, 2011 · Viewed 98.9k times · Source

I am trying to download a tarball from GitHub using cURL, but it does not seem to be redirecting:

$ curl --insecure https://github.com/pinard/Pymacs/tarball/v0.24-beta2
<html><body>You are being <a href="https://nodeload.github.com/pinard/Pymacs/tarball/v0.24-beta2">redirected</a>.</body></html>

Note: wget works for me:

$ wget --no-check-certificate https://github.com/pinard/Pymacs/tarball/v0.24-beta2

However I want to use cURL because ultimately I want to untar it inline with something like:

$ curl --insecure https://github.com/pinard/Pymacs/tarball/v0.24-beta2 | tar zx

I found that the URL after redirecting turned out to be https://download.github.com/pinard-Pymacs-v0.24-beta1-0-gcebc80b.tar.gz, but I would like cURL to be smart enough to figure this out.

Answer

saltycrane picture saltycrane · Apr 21, 2011

Use the -L option to follow redirects:

curl -L https://github.com/pinard/Pymacs/tarball/v0.24-beta2 | tar zx