Download a subdirectory from github
Written by Yannik Messerli - 15 March 2016
Have you ever needed to download only a subdirectory from a GitHub project without downloading the entire repository? Surprisingly, there doesn’t seem to be a way of doing this easily using Git. A somewhat unexpected solution is to use SVN.
First get the URL of the subfolder. GitHub URLs have the form:
https://github.com/author/repo-name/tree/master/subdirectory Then replace /tree/master/ with /trunk/ to get:
https://github.com/author/repo/trunk/subdirectory You can now download the subdirectory you’re interested in using SVN’s export command:
svn export https://github.com/author/repo/trunk/subdirectory For example, this command will download a “Hello World” Chrome extension sample from GitHub:
svn export https://github.com/GoogleChrome/chrome-app-samples/trunk/samples/hello-world