Created
September 8, 2022 00:48
-
-
Save colinhoglund/7d569e327625e3ae229ebd54636bc580 to your computer and use it in GitHub Desktop.
How To Delete Git Branches
This file contains hidden or 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
# prune remote branches that no longer exist | |
git fetch --prune origin | |
# dry-run list of branches to delete | |
git push --dry-run --delete origin $(git branch --remotes --merged | grep -vE 'HEAD|master|main' | cut -d\/ -f2- | xargs) | |
# delete branches | |
git push --delete origin $(git branch --remotes --merged | grep -vE 'HEAD|master|main' | cut -d\/ -f2- | xargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment