Freelance web & mobile app developer - Edinburgh, UK

Download a Git subdirectory from GitHub

January 30, 2015

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:

Then replace /tree/master/ with /trunk/ to get:

You can now download the subdirectory you’re interested in using SVN’s export command:

svn export

For example, this command will download a “Hello World” Chrome extension sample from GitHub:

svn export

Credit: Stack Overflow

Looking for an experienced full stack developer for your web or mobile project?
I'm available for contract work in Edinburgh and can also work remotely.