Skip to content

Instantly share code, notes, and snippets.

@K3TH3R
Created May 3, 2015 20:13
Show Gist options
  • Save K3TH3R/0299fee2684e62fae8e3 to your computer and use it in GitHub Desktop.
Save K3TH3R/0299fee2684e62fae8e3 to your computer and use it in GitHub Desktop.
Quickly setup Bitbucket/Github repos from your command line
# New Github repo
# -----------------------------
# Make sure to replace the "USERNAME" portion with your own
# GitHub username. To start a new public GitHub repo,
# simply do this from your command line:
# newgh REPO_NAME
function newgithub(){
curl -u 'USERNAME' https://api.github.com/user/repos -d "{\"name\":\"$1\"}";
git init;
git remote add origin git@github.com:USERNAME/$1.git;
echo "# $1" >> README.md;
git add -A;
git commit -m "Initial commit";
git push -u origin master;
}
alias newgh=newgithub
# New Private BitBucket repo
# -----------------------------
# Make sure to replace the "USERNAME" portion with your own
# BitBucket username. To start a new private Bitbucket repo,
# simply do this from your command line:
# newgh REPO_NAME
function newbitbucket(){
curl --user USERNAME https://api.bitbucket.org/1.0/repositories/ --data is_private='true' --data name=$1;
git init;
git remote add origin https://USERNAME@bitbucket.org/USERNAME/$1;
echo "# $1" >> README.md;
git add -A;
git commit -m "Initial commit";
git push -u origin master;
}
alias newbb=newbitbucket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment