Skip to content

Instantly share code, notes, and snippets.

@vcavallo
Last active January 8, 2017 06:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vcavallo/6818428 to your computer and use it in GitHub Desktop.
Save vcavallo/6818428 to your computer and use it in GitHub Desktop.
Create a GitHub repo from the CLI (plus bash function)

Create GitHub repo without leaving the command line

curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}'

Replace USER with your username and REPO with the intended repo name. Include all quotes above.

The do the usual:

git remote add origin git@github.com:USER/REPO.git
git push origin master

Woo Hoo! Now, to betterize it...

Bash function for this:

function gh-new () {
  curl -u 'USER' https://api.github.com/user/repos -d "{\"name\":\"$1\"}"
}

Again, replace USER when you use it in your own .bash_profile.

usage: $ gh-new repo-name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment