Last active
February 13, 2023 15:40
-
-
Save alanplatt/1b78f0623fb5c3128700d7bc177840ca to your computer and use it in GitHub Desktop.
Git function to delete all branches merged to default branch
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
_gbclean () { | |
default_branch=$( git remote show origin | sed -n '/HEAD branch/s/.*: //p') | |
git checkout "${default_branch}" && git pull && \ | |
for branch in $(git branch -l | grep -v -e "${default_branch}" ); do | |
git branch -d $branch | |
done | |
} | |
alias gbclean='_gbclean' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment