Created
September 10, 2019 04:17
-
-
Save zeuslawyer/d8c9381b862647bf56f7ab4df011dd17 to your computer and use it in GitHub Desktop.
script that lets you create and then push to remote repo in github. access from inside project root folder <<~/scripts>>/pushToRemote.sh
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/bash | |
# Make executable with chmod +x <<filename.sh>> | |
CURRENTDIR=${pwd} | |
# step 1: name of the remote repo. Enter a SINGLE WORD ..or...separate with hyphens | |
echo "What name do you want to give your remote repo?" | |
read REPO_NAME | |
echo "Enter a repo description: " | |
read DESCRIPTION | |
echo "What is your github username?" | |
read USERNAME | |
# step : add local changes, commit | |
git add . | |
git commit -m 'commit prior to pushing to remote' | |
# Step 5 use github API to log the user in | |
curl -u ${USERNAME} https://api.github.com/user/repos -d "{\"name\": \"${REPO_NAME}\", \"description\": \"${DESCRIPTION}\"}" | |
# Step 6 add the remote github repo to local repo and push | |
git remote add origin https://github.com/${USERNAME}/${REPO_NAME}.git | |
git push --set-upstream origin master | |
cd "$CURRENTDIR" | |
echo "Done. Go to https://github.com/$USERNAME/$REPO_NAME to see." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment