15

I have a repository that has several folders of code. I'd like to be able to provide a link to the code in a single folder so another user could download just the relevant bits of code without being bloated by the rest of the codebase and without requiring that they have git installed on their machine.

Of course, they can browse the code files inside of the folder online, but that isn't very helpful if they want to run a single project.

Here are several other similar questions, and why I don't think they address my particular issues:

In case it helps provide a concrete example, here's a folder that I would like to be able to download via a link:
https://github.com/KyleMit/CodingEverything/tree/master/MVCBootstrapNavbar/Source%20Code

Is there any way to do this?

Community
  • 1
  • 1
KyleMit
  • 30,350
  • 66
  • 462
  • 664
  • 1
    From [Kino](http://stackoverflow.com/users/2238770/kino), there is a project called [gitzip](http://kinolien.github.io/gitzip) that uses GitHub API, JSZip, and FileSaver.js to do this. – KyleMit Nov 17 '15 at 13:27

4 Answers4

15

Go to DownGit > enter the URL > simply download!

Your desired download link for https://github.com/KyleMit/CodingEverything/tree/master/MVCBootstrapNavbar/Source%20Code- DOWNLOAD [this link is no more valid as the repo folder moved]

Detailed usage HERE.


Disclaimer: I fell into the same problem as the question-asker, could not find any proper solution, so I created this tool for my own use, and later made it available for everyone.

logankilpatrick
  • 13,148
  • 7
  • 44
  • 125
Minhas Kamal
  • 20,752
  • 7
  • 62
  • 64
9

no, not through a direct link.

"Loading" a folder from a git repo only means sparse checkout (partial clone).

Any other solution would indeed mean building an artifact and upload it.

Update August 2016 (2 years later): you can have a look at this answer and the DownGit project, by Minhas Kamal.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks! Curiosity: does it seem hypothetically possible to put together a web service that would take a directory or file url as a parameter, download the appropriate repository, zip the appropriate files, and return them to the client? – KyleMit May 04 '14 at 22:59
  • 2
    @KyleMit In theory, yes: that is what GitHub did with its nodeload service (https://github.com/blog/678-meet-nodeload-the-new-download-server and https://github.com/blog/900-nodeload2-downloads-reloaded). It mainly depends on the number of request you expect. – VonC May 05 '14 at 12:09
  • If I understand, a "artifact" would mean a copy? So commits wouldn't update it automatically? –  May 26 '17 at 12:43
  • @DaniSpringer No, an artifact is a binary that you are building from the sources: here, a zip file from a specific folder from the sources. Meaning that it is indeed a copy, and commits won't update that artifact automatically. – VonC May 26 '17 at 12:58
  • @DaniSpringer a simple zip, an archive of the sources. That archive is a binary. – VonC May 26 '17 at 13:00
  • I don't understand. Oh well... Thanks anyways –  May 26 '17 at 13:02
  • @DaniSpringer the goal is to download a subfolder of the sources of the GitHub repo. My suggestion is to compress a copy of that subfolder, and upload it as a release: https://github.com/blog/1547-release-your-software. That way, any user would be able to download that "realease", which would be a compressed zip of the subfolder. – VonC May 26 '17 at 13:04
  • So an artifact is just another word for zip file? –  May 26 '17 at 13:05
  • @DaniSpringer artifact is a generic term (https://en.wikipedia.org/wiki/Artifact_(software_development)) referencing anything you are building from your sources. – VonC May 26 '17 at 13:06
  • Aha. I have a lot to learn. "building from sources" is a generic way to say "make zip file"? (or pyc file I guess?) –  May 26 '17 at 13:08
  • @DaniSpringer making a zip file is just one possibility to make an artifact: it depends on what you expect from your build process. In the context of this question, that is the artifact you want. But generally, building an artifact involve a compilation step, and the result is *not* a zip, but an executable. – VonC May 26 '17 at 13:11
  • Like pyc? So in order to make a downloadable release from a folder in a repo, I first need to download that folder, and make a release from it? Wold I need to make it it's own repo? –  May 26 '17 at 13:13
  • @DaniSpringer yes: clone the all repo, make a zip of the folder you want, upload it as a release (https://github.com/blog/1547-release-your-software) – VonC May 26 '17 at 13:15
  • I'm trying it out. Thank you! I just want you to know that I wasn't asking more questions without trying and looking things up... I know how SO (and the world?) should work. :) –  May 26 '17 at 13:15
  • Looks like it works :D Thanks again! - https://github.com/DaniSpringer/Projects/releases/latest –  May 26 '17 at 13:55
1

I developed a chrome extension using KinoLien's gitzip . Please find it here.

charany1
  • 871
  • 2
  • 12
  • 27
0

https://ghd.one allows you to download release files by filtering them down to a single file. Source files download will follow shortly.

More about GHD on reddit: https://www.reddit.com/r/programming/comments/o1yit0/ghd_get_github_direct_links_without_pain_wip/