Skip to content

Instantly share code, notes, and snippets.

@danielgomezrico
Last active August 31, 2020 16:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielgomezrico/6cefbd47fe28d68233ba10c491ee7fab to your computer and use it in GitHub Desktop.
Save danielgomezrico/6cefbd47fe28d68233ba10c491ee7fab to your computer and use it in GitHub Desktop.
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