Skip to content

Instantly share code, notes, and snippets.

@islomar
Last active August 29, 2015 13:55
Show Gist options
  • Save islomar/8755364 to your computer and use it in GitHub Desktop.
Save islomar/8755364 to your computer and use it in GitHub Desktop.
Using Github's API to create repositories from the command-line
http://robinwinslow.co.uk/2013/06/07/create-github-repositories-from-the-command-line/
# replace USER and REPO with real values
# but *not* the "/user/" in the GitHub URL
$ curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}'
# you will be prompted for your password
$ git remote add origin git@GitHub.com:USER/REPO.git
Create alias in git:
git config --global alias.gh-create '!sh -c "curl -u \"islomar\" https://api.github.com/user/repos -d \"{\\\"name\\\":\\\"$1\\\"}\" && git remote add origin git@github.com:islomar/$1.git" -'
Use alias:
$ git gh-create canvas-play # create the GitHub repository
$ git push -u origin master # push my repository to GitHub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment