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.

Revisions

  1. jerrykrinock revised this gist Jun 30, 2017. No changes.
  2. jerrykrinock revised this gist Jun 30, 2017. No changes.
  3. jerrykrinock revised this gist Jun 30, 2017. No changes.
  4. jerrykrinock revised this gist Jun 30, 2017. No changes.
  5. jerrykrinock revised this gist Jun 30, 2017. No changes.
  6. jerrykrinock revised this gist Jun 30, 2017. No changes.
  7. jerrykrinock revised this gist Jun 30, 2017. No changes.
  8. jerrykrinock revised this gist Sep 21, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gitcreate.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/bash

    # This script create a new repo on github.com, then pushes to it the local repo from the current directory.
    # This script create a new repo on github.com, then pushes the local repo from the current directory to the new remote.

    # It is a fork of https://gist.github.com/robwierzbowski/5430952/. Some of Rob's lines just didn't work for me, and to fix them I needed to make it more verbose so that a mere electrical engineer could understand it.

  9. jerrykrinock revised this gist Sep 19, 2013. 1 changed file with 39 additions and 13 deletions.
    52 changes: 39 additions & 13 deletions gitcreate.sh
    Original file line number Diff line number Diff line change
    @@ -1,25 +1,51 @@
    #!/bin/bash

    # This script create a new repo on github.com, then pushes to it the local repo from the current directory.

    # 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.
    # It is a fork of https://gist.github.com/robwierzbowski/5430952/. Some of Rob's lines just didn't work for me, and to fix them I needed to make it more verbose so that a mere electrical engineer could understand it.

    # This script gets a username from .gitconfig. If it indicates that your default username is an empty string, you can set it with
    # git config --add github.user YOUR_GIT_USERNAME

    # 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 "Enter name for new repo, or just <return> to make it $CURRENTDIR"
    read REPONAME
    echo "Enter username for new, or just <return> to make it $GITHUBUSER"
    read USERNAME
    echo "Enter description for your new repo, on one line, then <return>"
    read DESCRIPTION
    echo "Enter <return> to make the new repo public, 'x' for private"
    read PRIVATE_ANSWER

    echo "Here we go..."
    if [ "$PRIVATE_ANSWER" == "x" ]; then
    PRIVACYWORD=private
    PRIVATE_TF=true
    else
    PRIVACYWORD=public
    PRIVATE_TF=false
    fi

    # 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}"
    REPONAME=${REPONAME:-${CURRENTDIR}}
    USERNAME=${USERNAME:-${GITHUBUSER}}

    echo "Will create a new *$PRIVACYWORD* repo named $REPONAME"
    echo "on github.com in user account $USERNAME, with this description:"
    echo $DESCRIPTION
    echo "Type 'y' to proceed, any other character to cancel."
    read OK
    if [ "$OK" != "y" ]; then
    echo "User cancelled"
    exit
    fi

    # Curl some json to the github API oh damn we so fancy
    curl -u $USERNAME https://api.github.com/user/repos -d "{\"name\": \"$REPONAME\", \"description\": \"${DESCRIPTION}\", \"private\": $PRIVATE_TF, \"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
    git remote add origin https://github.com/$USERNAME/$REPONAME.git
    git push -u origin master
  10. @robwierzbowski robwierzbowski renamed this gist May 2, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  11. @robwierzbowski robwierzbowski revised this gist Apr 21, 2013. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion makerepo.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,9 @@
    #!/bin/bash

    # http://stackoverflow.com/questions/2423777/is-it-possible-to-create-a-remote-repo-on-github-from-the-cli-without-ssh/10325316#10325316
    # 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##*/}
  12. @robwierzbowski robwierzbowski created this gist Apr 21, 2013.
    22 changes: 22 additions & 0 deletions makerepo.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/bin/bash

    # http://stackoverflow.com/questions/2423777/is-it-possible-to-create-a-remote-repo-on-github-from-the-cli-without-ssh/10325316#10325316

    # 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