0

I have a git repo. In the left nav, there's an option to "Download". It downloads the master branch as a zip file. How do I do the same thing via the cli?

For some reason, when I use git clone, the data that it returns is not the same. I only know this because said data is ran through a Java program and the output is different depending on how it's pulled from git. I have tried getting this data lots of ways and the only way that works is manually downloading it from the GUI.

EDIT: Maybe a better way to ask this is: What command is being ran when I click the "Download" link?

EDIT 2: @Arkadiusz Drabczyk's solution in the comments of the "cliget" add-on in Firefox was a perfect solution. Much appreciated.

  • What operating system do you use? On `*nix` (`Linux`) for example you could use `wget`. – Arkadiusz Drabczyk May 05 '17 at 19:59
  • I could use wget, but I can't get the URL for the "Download" link. When I hover over it, if try to wget that URL, it's not equivalent to pressing the download button. It's like a redirect and I just wget a webpage essentially, rather than a zip – Carl_Friedrich_Gauss May 08 '17 at 14:30
  • Are you sure you use `github` because in `github` the `Clone or download` button is on the *right* side? – Arkadiusz Drabczyk May 08 '17 at 14:51
  • I'm actually using an internally hosted version of Stash; is the functionality that different? – Carl_Friedrich_Gauss May 08 '17 at 20:21
  • 1
    Yes, I think it's different. Consider this: https://addons.mozilla.org/en-US/firefox/addon/cliget/. I use it and can recommend it. It's an addon for generating `curl` commands, it automatically handles cookies etc. so I think it might be what you looking for. I just tried it on my account on `bitbucket` and it generated a `curl` command together with `Cookie:` part which allowed me to download a `.zip` file on behalf of the logged-in user from the command line. – Arkadiusz Drabczyk May 08 '17 at 20:28

1 Answers1

1

To get the content of a revision (say, the tip of a given branch... but it could be any other revision) on a zip file (say, some_zip_file.zip):

git archive --format=zip -o some_zip_file.zip master

eftshift0
  • 26,375
  • 3
  • 36
  • 60
  • Thanks. Do I have to have git cloned that repo first? – Carl_Friedrich_Gauss May 05 '17 at 20:32
  • Yep... if you only care about getting a single revision and you don't want to have a full clone of the repo, then do a shallow clone to be able to get the revision you want https://www.perforce.com/blog/141218/git-beyond-basics-using-shallow-clones – eftshift0 May 05 '17 at 20:35