tj.git-extras/bin/git-delete-branch
2014-11-30 17:47:26 +05:30

21 lines
497 B
Bash
Executable file

#!/usr/bin/env bash
# Assert there is at least one branch provided
test -z $1 && echo "branch required." 1>&2 && exit 1
# Concatenate all branch references
local_branches=""
origin_branches=""
origin_refs=""
for branch in "$@"
do
local_branches=$local_branches" $branch"
origin_branches=$origin_branches" origin/$branch"
origin_refs=$origin_refs" :refs/heads/$branch"
done
# Delete all branches
git branch -D $local_branches
git branch -d -r $origin_branches
git push origin $origin_refs