Skip to content

Instantly share code, notes, and snippets.

@pandabamboo90
Forked from schacon/gist:942899
Last active January 27, 2024 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandabamboo90/c7f5267266b3dbdf5fe601e97cbed8c1 to your computer and use it in GitHub Desktop.
Save pandabamboo90/c7f5267266b3dbdf5fe601e97cbed8c1 to your computer and use it in GitHub Desktop.
delete all remote branches that have already been merged into master & develop
git fetch --prune
for branch in $(git branch -r --merged master | grep origin | grep -v develop | grep -v master)
do
MARK_FOR_DELETE_BRANCHES+=" ${branch#*/}"
done
# echo $MARK_FOR_DELETE_BRANCHES
# Delete the branches
git push origin --delete $MARK_FOR_DELETE_BRANCHES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment