Last active
February 17, 2023 17:16
-
-
Save bricss/dc19e73b05bf6e5a2cd1c0457aa489f2 to your computer and use it in GitHub Desktop.
Remove remote merged branches from Git repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Removes remote merged branches from Git repo | |
# Usage: `sh git-broom.sh` | |
protect='(dev|main|master|release)' | |
git fetch --prune --tags origin | |
git branch --remotes --merged origin | grep origin | grep -v $(git symbolic-ref --short HEAD) | egrep -v $protect | sed s/origin\\/// | xargs git push origin --delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment