I am trying to download a .zip file from GitHub using the command line in Ubuntu. I am using wget command for it on a remote Ubuntu system.

I run wget <link> where <link> is the address bar link of the file which I want to download. It ends with archive.zip?ref=master.

Now, when I am executing the command, it is downloading a file with text/html type and not the .zip file which I want.

Please tell me how to get the link to be given as the parameter of wget. Right now, I am just copying the link address of the button (using right click) and writing that as a wget parameter.

  • can you tell the exact command you are pasting? – kashish Jul 26 '17 at 5:10
  • 1
    Does your URL really ends with .zip? – kashish Jul 26 '17 at 5:11
  • @kashish No the URL does not end with .zip . I am trying to download a project from github and it has a download button giving zip and other options. So, I'm trying from there. it ends with archive.zip?ref=master – UbuntuCoder Jul 26 '17 at 5:13
  • To download a github project, you can use git clone <projectlink.git> – kashish Jul 26 '17 at 5:19
  • If I'm not mistaken it possible to download a repository as Zip-file using a following address: https://github.com/{user}/{repo}/archive/{branch}.zip – Alex Chermenin Jul 26 '17 at 8:22

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..

  • 2
    After cloning, do git archive -o output.zip, if a zip file is still needed – Ferrybig Jul 30 '17 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.