Skip to content

Instantly share code, notes, and snippets.

@maurobringolf
Last active April 22, 2019 20:25
Show Gist options
  • Save maurobringolf/b8840bccc4162ce423410b5ba3df6520 to your computer and use it in GitHub Desktop.
Save maurobringolf/b8840bccc4162ce423410b5ba3df6520 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
git branch | grep -v $(git rev-parse --abbrev-ref HEAD) | xargs git branch -D
@math2001
Copy link

math2001 commented Oct 1, 2017

Doesn't work if you have a branch called master and an other branch called master-beta for examle. You might need to use a regex.

@maurobringolf
Copy link
Author

maurobringolf commented Oct 2, 2017

@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