caipivara
4/29/2016 - 8:07 PM

Bash / Git - remove local and remote branches for repo cleanup

Bash / Git - remove local and remote branches for repo cleanup

#!/usr/bin/env sh
#
# Remove from local and remotes the branches inside
# BRANCHES array
#

BRANCHES=( 
    branch_1
    feature/branch_2
    feature/other_thing
)

for branch_name in ${BRANCHES[*]}
do
	git branch "-d" $branch_name
	git push origin :$branch_name
done

git fetch -p