Skip to content

Instantly share code, notes, and snippets.

@jerrykrinock
Forked from robwierzbowski/gitcreate.sh
Last active October 10, 2025 20:22
Show Gist options
  • Select an option

  • Save jerrykrinock/6618003 to your computer and use it in GitHub Desktop.

Select an option

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 :)
#!/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
@shinokada
Copy link
Copy Markdown

I used two-factor authentication. Any idea to add this too?

@jerrykrinock
Copy link
Copy Markdown
Author

Wow. I didn't know github was doing two-factor. Sorry, I have no plans to do that.

@drzax
Copy link
Copy Markdown

drzax commented Jul 3, 2017

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