Well, Most of the times I see hundreds of projects in a single repo. Now, if I don’t want to download a GB of code and then eventually use just 20mb of it. How is it fare?
So I wanted to create a downloader for it. Turns out I’m a little too late. There are already a couple of options which work flawlessly.
Go ahead and give it a try!
- GitZip (Credits to Kino – upvote his answer right here!)
- DownGit (Credits to Minhas Kamal – upvote his answer right here!)
Git doesn’t support this, but Github does via SVN. If you checkout your code with subversion, Github will essentially convert the repo from git to subversion on the backend, then serve up the requested directory.
Here’s how you can use this feature to download a specific folder. I’ll use the popular javascript librarylodash
as an example.
- Get the repo URL. First, copy the URL of the Github repo to your clipboard.
- Modify the URL for subversion. I want to download the folder at
/docs
from themaster
branch, so I will appendtrunk/docs
. Full URL is nowhttps://github.com/lodash/lodash/trunk/docs
. See my note below for a more in-depth explanation of why we must use this URL format. - Download the folder. Go to the command line and grab the folder with SVN.
svn checkout https://github.com/lodash/lodash/trunk/docs
You might not see any activity immediately because Github takes up to 30 seconds to convert larger repositories, so be patient.
Full URL format explanation:
- If you’re interested in
master
branch, usetrunk
instead. So the full path istrunk/foldername
- If you’re interested in
foo
branch, usebranch/branchname
instead. The full path looks likebranch/branchname/foldername
- Protip: You can use
svn ls
to see available tags and branches before downloading if you wish
That’s all! Github supports more subversion features as well, including support for committing and pushing changes.