#!/bin/bash
#
# check whether current directory is inside a git repository
#

is_git_repo() {
  git rev-parse --show-toplevel > /dev/null 2>&1
  result=$?
  if test $result != 0; then
    >&2 echo 'Not a git repo!'
    exit $result
  fi
}

is_git_repo

echo 'setting up gh-pages'
git symbolic-ref HEAD refs/heads/gh-pages \
  && rm .git/index \
  && git clean -fdx \
  && echo 'My Page' > index.html \
  && git add . \
  && git commit -a -m 'Initial commit' \
  && git push -u origin gh-pages \
  && git fetch origin \
  && echo 'complete'
