Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment