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.

GitHub: Creating Repositories and Opening/Closing Issues Entirely from the Terminal

You can delegate almost everything essential for git and github to the command line. There two obvious missing links: creating repositories and handling project issues. Here are two tools that allow you to complete these tasks.

Hub for creating repositories from the command line 

1. Install hub using brew with the command

brew install hub

2. Init your repository and do your first commit.

git init 
git add -A
git commit -m "First Commit"

3. Create the repository using Hub’s create command

git create -d "New Project"

4. It may ask you to log in with your GitHub credentials at this step

5. Push to your new repository!

git push origin master

GHI to handle GitHub issues from the command line

1. Install GHI using brew

brew install ghi

2. That’s it! Now you can use ghi to open, close, and edit your issues. Here’s a list of useful commands from the github page

usage: ghi [--version] [-p|--paginate|--no-pager] [--help] <command> [<args>]
           [ -- [<user>/]<repo>]

The most commonly used ghi commands are:
   list        List your issues (or a repository's)
   show        Show an issue's details
   open        Open (or reopen) an issue
   close       Close an issue
   lock        Lock an issue's conversation, limiting it to collaborators
   unlock      Unlock an issue's conversation, opening it to all viewers
   edit        Modify an existing issue
   comment     Leave a comment on an issue
   label       Create, list, modify, or delete labels
   assign      Assign an issue to yourself (or someone else)
   milestone   Manage project milestones
   status      Determine whether or not issues are enabled for this repo
   enable      Enable issues for the current repo
   disable     Disable issues for the current repo

See 'ghi help <command>' for more information on a specific command.