Skip to content

Instantly share code, notes, and snippets.

@turboBasic
Last active January 4, 2021 13:38
Show Gist options
  • Save turboBasic/f39f93e36db2b520708ad072217dc0b4 to your computer and use it in GitHub Desktop.
Save turboBasic/f39f93e36db2b520708ad072217dc0b4 to your computer and use it in GitHub Desktop.
create Github repo from command line using Github REST API with correct escaping #shell #git #github
#!/bin/sh
# Create repository in Github with correct escaping in repo name
# Requires {@code GITHUB_TOKEN} env var.
# @return ssh url to created repository which can be used in git clone command
jq --null-input --compact-output \
--arg repo 'my-awesome-project' \
'{name: $repo}' \
| curl \
--header "Authorization: token $GITHUB_TOKEN" \
--data @- \
https://api.github.com/user/repos \
| jq --raw-output .ssh_url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment