If you’re like me, you hate swapping out of terminal to log into GitHub when creating a new repository. It an always jarring step that gets you out of coding flow. You can accomplish the very same thing at the command line, and never open a web browser. All you need is the cURL library (found in almost every popular flavor of Linux and OSX today), and your personal GitHub API token.
This technique calls on GitHub’s API to work its magic. You will therefore need to login to GitHub, browse to the “Your Account – Account Admin” section and find your unique API token listed there. Copy the token down for reference purposes.
When you are ready to create a new GitHub repository for your code (ie: just before “git remote add origin” step), issue the following command using the cURL URL transfer tool:
$ curl -F 'login=<your_login_name>' -F 'token=<your_API_token>' https://github.com/api/v2/json/repos/create -F 'name=<your_repo_name>' -F 'description=<your_repo_summary>'
GitHub will reply to your API call with a flurry of JSON, while it creates your new repo in the background:
Your repo will now be ready to push code into. Login into GitHub to validate that it is indeed there. That’s it!
UPDATE 1/10/2013: Github terminated its API on June 1, 2012, which negates the ability to create the repo. More detail can be found here.