Created
March 23, 2021 12:08
-
-
Save julianburr/4ce05db39c58b1d1e4fbeb3c0255db0f to your computer and use it in GitHub Desktop.
Git - delete merged branches locally and remote
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
# https://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-have-been-merged | |
# Delete local branches that have been merged i.e. into "main" | |
git branch --merged main | grep -v "(^\*|main)" | xargs git branch -d | |
# Delete remote branches that have been merged i.e. into "main | |
git branch -r --merged main | grep -v "(^\*|main)" | sed 's/origin\///' | xargs -n 1 git push --delete origin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment