How to Download Subdirectory of a GitHub Project

Sometimes we only need to download a portion of a project that is hosted on GitHub. And the size of the entire project is too big to consider downloading the whole master.zip file. Fortunately it is possible to do with a help of Subversion (SVN) program.

Aside from Git program which is the native repository format used by GitHub, they also let users to use SVN to work on the repository. Unlike Git, SVN allows us to checkout (SVN’s equivalent to Git’s clone command) a subdirectory. To do this, use the following command:

# to download from HEAD (i.e. master)
svn checkout https://github.com/USER/REPO/trunk/PATH-TO-SUBDIRECTORY DEST
# to download from another branch
svn checkout https://github.com/USER/REPO/branches/BRANCH/PATH-TO-SUBDIRECTORY DEST

Change USER and REPO with the correct user and repository name, and DEST with your desirable folder in your local computer. If DEST is omitted, it will create a folder named the checked-out subdirectory.

If you wish to download only the files without version control data, akin to downloading the zip file from GitHub, use svn export command instead.

svn export https://github.com/USER/REPO/trunk/PATH-TO-SUBDIRECTORY DEST

For example, let’s say you would like to grab a copy of Obsidian folder from madmaxms/iconpack-0bsidian project repository.

svn export https://github.com/madmaxms/iconpack-obsidian/trunk/Obsidian