Skip to content

Instantly share code, notes, and snippets.

@Apreche
Created November 17, 2010 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Apreche/703685 to your computer and use it in GitHub Desktop.
Save Apreche/703685 to your computer and use it in GitHub Desktop.
Create a github repository from the current directory
#!/bin/bash
# This will turn the current directory into a repo on Github
# Set the username and password as environment variables like so, in bashrc:
# export GITHUB_USER="User Name Goes Here"
# export GITHUB_TOKEN="API Token Goes Here"
CWD=`basename $PWD`
curl -F "login=$GITHUB_USER" -F "token=$GITHUB_TOKEN" https://github.com/api/v2/yaml/repos/create -F "name=$CWD"
REPO_URL="git@github.com:$GITHUB_USER/$CWD.git"
if [ ! -d $PWD/.git ]; then
git init
touch README
git add README
git commit -m "first commit"
fi
git remote add origin $REPO_URL
git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment