Created
December 25, 2013 20:39
-
-
Save thejsj/8126742 to your computer and use it in GitHub Desktop.
Shell script to create github repo remotely using the github API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 [email protected]: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