Commit | Line | Data |
---|---|---|
14d18581 JA |
1 | #!/bin/bash |
2 | ||
3 | if [ ! -d .git ]; then | |
4 | echo Does not appear to be a git tree | |
5 | exit 1 | |
6 | fi | |
7 | ||
8 | if [ ! -f .git/refs/heads/$1 ]; then | |
9 | echo $1 does not appear to be a valid branch | |
10 | exit 1 | |
11 | fi | |
12 | ||
13 | HEAD_SHA=$(cat .git/HEAD) | |
14 | BRANCH_SHA=$(cat .git/refs/heads/$1) | |
15 | ||
16 | if [ $HEAD_SHA == $BRANCH_SHA ]; then | |
17 | echo Cannot remove current branch | |
18 | exit 1 | |
19 | fi | |
20 | ||
21 | rm -rf .git/refs/heads/$1 | |
22 | git prune | |
23 | ||
24 | exit 0 |