Generate download link for a single folder in GitHub

38,576

Solution 1

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.

Solution 2

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.

Solution 3

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

Share:
38,576
KyleMit
Author by

KyleMit

I've been writing software for the last decade or so at StackOverflow, DealerPolicy, the Vermont Department of Health, code camps, meetups, and online. I'm primarily focused on web dev, react, dotnet, and azure, but always in the mood to debug something new. Favorite SO Accomplishments: 67k+ rep given away via bounties - currently 1st of all time twitter-bootstrap - 3rd person to get the Gold Badge Socratic - Asked a well-received question on 100 separate days Sportsmanship - Up vote 100 answers on questions where an answer of yours has a positive score Refiner - Edit and answer 50 questions

Updated on July 09, 2022

Comments

  • KyleMit
    KyleMit almost 2 years

    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?

  • KyleMit
    KyleMit almost 10 years
    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?
  • VonC
    VonC almost 10 years
    @KyleMit In theory, yes: that is what GitHub did with its nodeload service (github.com/blog/678-meet-nodeload-the-new-download-server and github.com/blog/900-nodeload2-downloads-reloaded). It mainly depends on the number of request you expect.
  • Dani
    Dani almost 7 years
    If I understand, a "artifact" would mean a copy? So commits wouldn't update it automatically?
  • VonC
    VonC almost 7 years
    @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
    VonC almost 7 years
    @DaniSpringer a simple zip, an archive of the sources. That archive is a binary.
  • Dani
    Dani almost 7 years
    I don't understand. Oh well... Thanks anyways
  • VonC
    VonC almost 7 years
    @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: 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.
  • Dani
    Dani almost 7 years
    So an artifact is just another word for zip file?
  • VonC
    VonC almost 7 years
    @DaniSpringer artifact is a generic term (en.wikipedia.org/wiki/Artifact_(software_development)) referencing anything you are building from your sources.
  • Dani
    Dani almost 7 years
    Aha. I have a lot to learn. "building from sources" is a generic way to say "make zip file"? (or pyc file I guess?)
  • VonC
    VonC almost 7 years
    @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.
  • Dani
    Dani almost 7 years
    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?
  • VonC
    VonC almost 7 years
    @DaniSpringer yes: clone the all repo, make a zip of the folder you want, upload it as a release (github.com/blog/1547-release-your-software)
  • Dani
    Dani almost 7 years
    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. :)
  • Dani
    Dani almost 7 years
    Looks like it works :D Thanks again! - github.com/DaniSpringer/Projects/releases/latest