Generate download link for a single folder in GitHub
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.
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, 2022Comments
-
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:
-
How to download source in .zip format from GitHub?
- Only provides a way to download the entire project, otherwise perfect.
-
Github download folder as zip
- This answer is for build artifacts. I don't want to upload the source code twice just so I can provide a download link to it.
-
Download a single folder or directory from a GitHub repo
- Requires using git commands to get a single folder. I'd rather have the link accessible to multiple people without requiring they have git installed.
-
GitHub - Download single files
- Only provides mechanism for downloading single files, not folders
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%20CodeIs there any way to do this?
-
How to download source in .zip format from GitHub?
-
KyleMit almost 10 yearsThanks! 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 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 almost 7 yearsIf I understand, a "artifact" would mean a copy? So commits wouldn't update it automatically?
-
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 almost 7 years@DaniSpringer a simple zip, an archive of the sources. That archive is a binary.
-
Dani almost 7 yearsI don't understand. Oh well... Thanks anyways
-
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 almost 7 yearsSo an artifact is just another word for zip file?
-
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 almost 7 yearsAha. I have a lot to learn. "building from sources" is a generic way to say "make zip file"? (or pyc file I guess?)
-
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 almost 7 yearsLike 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 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 almost 7 yearsI'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 almost 7 yearsLooks like it works :D Thanks again! - github.com/DaniSpringer/Projects/releases/latest