Skip to content

Instantly share code, notes, and snippets.

@bmizerany
Created March 29, 2010 23:30
Show Gist options
  • Save bmizerany/348549 to your computer and use it in GitHub Desktop.
Save bmizerany/348549 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
API="http://github.com/api/v2/json/repos/create"
function die() {
echo >&2 "$1"
exit 1
}
function usage() {
die "Usage: $0 repo-name [-p]"
}
# name is required
[ $# -lt 1 ] && usage
name=$1
public=0
while getopts p o; do
case "$o" in
p)
public=1
;;
*)
usage
;;
esac
done
# Grab credentials
user=$(git config github.user)
token=$(git config github.token)
if [ -z "$user" -o -z "$token" ]; then
die 'You need to set github.user and github.token; see `git help config`'
fi
# Make the request
curl -F "login=$user" \
-F "token=$token" \
-F "name=$name" \
-F "public=$public" \
"$API" 2>&1 1> /dev/null
[ ! -d .git ] && exit
# clone/push url
git="[email protected]:$user/$name.git"
echo "Adding remote github for $git"
git remote add github "$git"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment