Download a single directory from a repo on github

I went looking for “how download a single directory from within a repo on github”. Here’s what I found in their documentation – https://developer.github.com/v3/repos/contents/#get-archive-link. Below is my interpretation of that doc, having spent a total of 30 seconds reading it. Maybe if I spend another 30 seconds at some point, I’ll find out how to actually get just a single folder, instead of the whole repository (just as an archive, so no .git history). But this is what I ended up doing.

1. Construct a url starting with https://api.github.com/repos/
2. Follow that with the repository owner, the name of the repo, and format you’d like to download
3. curl it

curl -L https://api.github.com/repos/Automattic/vip-go-mu-plugins/tarball > tarball.tar

After that, I used the somewhat lazy method of opening the directory in the finder and untarring it with Mac’s Archive utility, instead of using the command line, pulled out the folder I wanted, and deleted the rest.

Advertisements