#!/bin/sh
if [ $# -ne 1 ]; then
  2<&1
  echo "usage: git emptybranch <new_branch>"
  exit 1
fi

if ! git check-ref-format refs/heads/"$1"; then
  2<&1
  echo "fatal: '$1' is not a valid branch name."
  exit 1
fi

git symbolic-ref -m "git emptybranch $1" HEAD refs/heads/"$1"
git rm --cached -r -q --ignore-unmatch -- '*'
