Last active
April 22, 2019 20:25
-
-
Save maurobringolf/b8840bccc4162ce423410b5ba3df6520 to your computer and use it in GitHub Desktop.
Deletes all local Git branches except the current one. See https://maurobringolf.ch/2017/09/how-to-delete-all-local-git-branches-except-current-one-in-bash/
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
#!/usr/bin/env bash | |
git branch | grep -v $(git rev-parse --abbrev-ref HEAD) | xargs git branch -D |
@math2001 Yup you are right. Someone suggested an improvement which should fix your issue as well I think: https://dev.to/maurobringolf/bash-exercise-delete-all-local-git-branches-except-current-one-9a6/comments/10pc.
The improved version is here: https://gist.github.com/maurobringolf/d21e92cf3a1715e35c800db9b869a1a4
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't work if you have a branch called
master
and an other branch calledmaster-beta
for examle. You might need to use a regex.