Last active
January 19, 2022 02:14
-
-
Save margauxflores/16cd5534db9cba4c082babab4c4d2f0b to your computer and use it in GitHub Desktop.
Clean Up Local Git Branches
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
# For the master branch | |
# Delete all local branches except master | |
$ git branch | grep -v "master" | xargs git branch -D | |
# Delete all local branches except those containing 'master' | |
$ git branch | grep -ve " master$" | xargs git branch -D | |
--- | |
# For the develop branch | |
# Delete all local branches except master | |
$ git branch | grep -v "develop" | xargs git branch -D | |
# Delete all local branches except those containing 'master' | |
$ git branch | grep -ve " develop$" | xargs git branch -D | |
--- | |
# Delete all merged branches | |
$ git branch --merged | grep -v \* | xargs git branch -D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment