-
-
Save jerrykrinock/6618003 to your computer and use it in GitHub Desktop.
This script creates a new repo on github.com, then pushes to it the local repo from the current directory. Fork of https://gist.github.com/robwierzbowski/5430952/. Some of Rob's lines just didn't work for me, and I made it more verbose while fixing. UPDATE 2017-06-30. No longer needed by Xcode users because this capability is built into Xcode 9 :)
This file contains hidden or 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 | |
| # https://gist.github.com/robwierzbowski/5430952/ | |
| # Create and push to a new github repo from the command line. | |
| # Grabs sensible defaults from the containing folder and `.gitconfig`. | |
| # Refinements welcome. | |
| # Gather constant vars | |
| CURRENTDIR=${PWD##*/} | |
| GITHUBUSER=$(git config github.user) | |
| # Get user input | |
| read "REPONAME?New repo name (enter for ${PWD##*/}):" | |
| read "USER?Git Username (enter for ${GITHUBUSER}):" | |
| read "DESCRIPTION?Repo Description:" | |
| echo "Here we go..." | |
| # Curl some json to the github API oh damn we so fancy | |
| curl -u ${USER:-${GITHUBUSER}} https://api.github.com/user/repos -d "{\"name\": \"${REPONAME:-${CURRENTDIR}}\", \"description\": \"${DESCRIPTION}\", \"private\": false, \"has_issues\": true, \"has_downloads\": true, \"has_wiki\": false}" | |
| # Set the freshly created repo to the origin and push | |
| # You'll need to have added your public key to your github account | |
| git remote set-url origin git@github.com:${USER:-${GITHUBUSER}}/${REPONAME:-${CURRENTDIR}}.git | |
| git push --set-upstream origin master |
Author
Wow. I didn't know github was doing two-factor. Sorry, I have no plans to do that.
Any more info about xcode integration? I can't find any docs on it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used two-factor authentication. Any idea to add this too?