Skip to content

Instantly share code, notes, and snippets.

@AaronSeibert
Created January 5, 2012 15:53
Show Gist options
  • Save AaronSeibert/1565820 to your computer and use it in GitHub Desktop.
Save AaronSeibert/1565820 to your computer and use it in GitHub Desktop.
Bash function for creating a new project and automatically creating a new repo on github
function newproject {
username=""
apikey=""
apiurl="http://github.com/api/v2/"
apiformat="json"
name=$@
# Create the repo on github
curl -F "login=${username}" -F "token=${apikey}" $apiurl$apiformat/repos/create -F "name=${name}"
# Create the working and testing folders for the project
mkdir -p ~/dev/public/$name
mkdir -p ~/dev/testing/$name
cd ~/dev/public/$name
# Initiate the git local git repo
git init
# create the README and add it awhile
touch README
git add README
# set the remote repo info
git remote add origin git@github.com:$username/$name.git
# commit the README and push it to make sure we can hit the repo
git commit -am "Initial Commit"
git push -u origin master
# sync the working directory and testing directory
cptest $name
}
function cptest {
project=$@
rsync -rsvu --exclude .git ~/dev/public/$project/ ~/dev/testing/$project
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment