--- /dev/null
+#!/bin/sh
+# git-empty-branch [branch]
+
+if [ $# -eq 1 ]; then
+ branch=$1
+else
+ echo "Usage: $0 [branch]" >&2
+ exit 1
+fi
+
+if [ -n "$(git show-ref --heads $branch)" ]; then
+ echo "branch already exists" >&2
+ exit 1
+fi
+
+git symbolic-ref HEAD refs/heads/$branch && \
+ rm .git/index && git clean -fdx && \
+ echo "Now on empty branch $branch" || \
+ fail
+exit 0
+
+fail()
+{
+ echo "Branch failure. You may need to git reset --hard" >&2
+ exit 1
+}