Last active
January 25, 2023 07:36
-
-
Save adedayojs/f18b69dd9661cd464157231630bcad23 to your computer and use it in GitHub Desktop.
Delete git branch locally
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
# To delete all branches except for the current branch in one step: | |
git branch | grep -v $(git rev-parse --abbrev-ref HEAD) | xargs git branch -D | |
# Delete all branches except a specific branch: | |
git branch | grep -v "branch name" | xargs git branch -D | |
# Delete all branches except some specific branch: | |
git branch | grep -v "branch name" | grep -v "branch name" | xargs git branch -D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment