How to Download a Given Folder in a Github Repository via SVN

There are times we download or clone a full GitHub repository when all that is needed is a given folder in it.

Say (like me) you use PHP Code Sniffer Tool to analyze and detect violations of a defined coding standard in PHP code and you’ve decided to include PSR2 standard to your list of installed standards.

Instead of the old way of cloning or downloading the whole repository, i will show you how to download just the PSR2 folder via Apache Subversion (SVN).

Note: i use TortoiseSVN rather than using SVN on the command line thus it will be used in this tutorial.

  1. Navigate to the directory in your computer where you want to the GitHub folder (PSR2) to be installed.
  2. Right-click and select export sub-menu under TortoiseSVN.

    SVN Export - TortoiseSVN

  3. This is the part where i reveal the trick. to convert a Github git repo to svn, replace the tree/master in
    https://github.com/squizlabs/PHP_CodeSniffer/tree/master/CodeSniffer/Standards

    to trunk making the url to be

    https://github.com/squizlabs/PHP_CodeSniffer/trunk/CodeSniffer/Standards/PSR2
  4. Enter the url as the svn repository url and hit the Ok button.
    SVN Export initiated - TortoiseSVN
    SVN Export initiated – TortoiseSVN
  5. After some time, SVN will download the folder to your computer.
    SVN export completed.
Don’t miss out!
Subscribe to My Newsletter
Invalid email address