Skip to content

Instantly share code, notes, and snippets.

@mattdesl
Last active August 29, 2015 14:07
Show Gist options
  • Save mattdesl/c11d2cd0b6d0bef2c4b9 to your computer and use it in GitHub Desktop.
Save mattdesl/c11d2cd0b6d0bef2c4b9 to your computer and use it in GitHub Desktop.
push current module folder to a new GitHub repository
  • Copy ghrepo.sh to ~/.
  • Setup permissions.
cd ~/
chmod +x ./ghrepo.sh
  • In ~/.bash_profile, add the following alias:
    alias ghrepo=$HOME/ghrepo.sh
  • Install modified gh and package-field tools:
    npm install gh package-field -g

After restarting terminal:

#go to folder you want to push to GitHub
cd my-app

#make sure you are logged in before publishing (only needed once)
gh user --login

#push current folder to a new repo: gitusername/my-app
ghrepo
#currently OSX only
#npm install gh package-field -g
#force user to login
gh user
#get username
GHUSER=`gh user --whoami`
DIR=${PWD##*/}
REPO=https://github.com/$GHUSER/$DIR.git
DESCRIPTION=`package-field description -s`
#confirm
read -r -p "Create a new repo at $GHUSER/$DIR? (Y/n)" REPLY
if [[ $REPLY == "" ]] || [[ $REPLY =~ ^[yY]$ ]]
then
# create repo
gh re --new $DIR --description "$DESCRIPTION"
touch README.md
git init
git add .
git commit -m 'first commit'
git remote add origin $REPO
git push -u origin master
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment