Skip to main content

Bash Script to Setup Git Repos

REPO_NAME=$1
GIT_USER='tingiris'
GIT_ORG='dabblelab'
test -z $REPO_NAME && echo "Repo name required." 1>&2 && exit 1

#for a user repo
#curl -u 'tingiris' https://api.github.com/user/repos -d "{\"name\":\"$REPO_NAME\"}"

#for an organization repo
curl -u $GIT_USER https://api.github.com/orgs/$GIT_ORG/repos -d "{\"name\":\"$REPO_NAME\"}"

cd $REPO_NAME
git init
git remote add origin "https://github.com/$GIT_ORG/$REPO_NAME.git"

printf "_tmp/\nconfig.js\ngitsetup.sh" > .gitignore
# printf "# $REPO_NAME\n" > README.md
git add .
git commit -m "Initial commit"

# git remote -v
git push -u origin master