#!/bin/bash if [ ! -d .git ]; then echo Does not appear to be a git tree exit 1 fi if [ ! -f .git/refs/heads/$1 ]; then echo $1 does not appear to be a valid branch exit 1 fi HEAD_SHA=$(cat .git/HEAD) BRANCH_SHA=$(cat .git/refs/heads/$1) if [ $HEAD_SHA == $BRANCH_SHA ]; then echo Cannot remove current branch exit 1 fi rm -rf .git/refs/heads/$1 git prune exit 0