How do I download a tarball from GitHub using cURL?

前端 未结 5 1538
旧时难觅i
旧时难觅i 2020-12-02 04:48

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/         


        
相关标签:
5条回答
  • 2020-12-02 05:39

    Use the -L option to follow redirects:

    curl -L https://github.com/pinard/Pymacs/tarball/v0.24-beta2 | tar zx
    
    0 讨论(0)
  • 2020-12-02 05:41

    You can also use wget to »untar it inline«. Simply specify stdout as the output file (-O -):

    wget --no-check-certificate https://github.com/pinard/Pymacs/tarball/v0.24-beta2 -O - | tar xz
    
    0 讨论(0)
  • 2020-12-02 05:45

    The modernized way of doing this is:

    curl -sL https://github.com/user-or-org/repo/archive/sha1-or-ref.tar.gz | tar xz
    

    Replace user-or-org, repo, and sha1-or-ref accordingly.

    If you want a zip file instead of a tarball, specify .zip instead of .tar.gz suffix.

    You can also retrieve the archive of a private repo, by specifying -u token:x-oauth-basic option to curl. Replace token with a personal access token.

    0 讨论(0)
  • 2020-12-02 05:46

    All the other solutions require specifying a release/version number which obviously breaks automation.

    This solution- currently tested and known to work with Github API v3- however can be used programmatically to grab the LATEST release without specifying any tag or release number and un-TARs the binary to an arbitrary name you specify in switch --one-top-level="pi-ap". Just swap-out user f1linux and repo pi-ap in below example with your own details and Bob's your uncle:

    curl -L https://api.github.com/repos/f1linux/pi-ap/tarball | tar xzvf - --one-top-level="pi-ap" --strip-components 1
    
    0 讨论(0)
  • 2020-12-02 05:46

    with a specific dir

    cd your_dir && curl -L https://download.calibre-ebook.com/3.19.0/calibre-3.19.0-x86_64.txz | tar zx

    0 讨论(0)
提交回复
热议问题