Skip to content

Instantly share code, notes, and snippets.

@thejsj
Created December 25, 2013 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thejsj/8126742 to your computer and use it in GitHub Desktop.
Save thejsj/8126742 to your computer and use it in GitHub Desktop.
Shell script to create github repo remotely using the github API
#!/bin/sh
REPO_NAME=$1
echo "NEW REPO NAME: $REPO_NAME"
echo -n "Are you sure you want to create github repo with name '$REPO_NAME' ? (y/n) > "
if read -t 5 response; then
if [ 'y' = "$response" ]; then
echo "Ok. Let's continue creating Repo"
echo "Creating Repository: $REPO_NAME"
curl -u 'thejsj' https://api.github.com/user/repos -d "{\"name\":\"$REPO_NAME\"}"
# Remember replace USER with your username and REPO with your repository/application name!
echo "Remote Add Origin: $REPO_NAME"
git remote add origin git@github.com:thejsj/$REPO_NAME.git
echo "Push Origin Master: $REPO_NAME"
git push origin master
# Create Direcotry and clone?
echo -n "Create Direcotry for '$REPO_NAME' ? (y/n) > "
if read -t 5 response_create_dir; then
if [ 'y' = "$response_create_dir" ]; then
cd ~/Sites/2013/
mdkir $REPO_NAME
git clone git://github.com/thejsj/$REPO_NAME.git
cd ./$REPO_NAME
else
echo "Repo Creation Failed. Come again soon!"
fi;
else
echo "Sorry, you are too slow!"
fi;
else
echo "Repo Creation Failed. Come again soon!"
fi;
else
echo "Sorry, you are too slow!"
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment