Using Subversion to Export GitHub Subdirectories

The other day I was trying to download part of an absolutely massive GitHub repository and it took quite a bit of googling to figure out how to do it quickly. I ended up finding a great way to do it using Apache Subversion from the command line.

First, install subversion through brew

brew install subversion

Then, get the directory URL directly from github. For demonstration purposes, I’ll grab a random directory from the postgres repository

https://github.com/postgres/postgres/tree/master/contrib/dict_xsyn

There is one change we have to make to the URL before it can work with SVN, replace tree/master with trunk and paste it into the console in the appropriate directory.

svn export https://github.com/postgres/postgres/trunk/contrib/dict_xsyn

That should automatically retrieve the correct directory and any subdirectories.