Created
February 19, 2012 04:02
-
-
Save ecavazos/1861874 to your computer and use it in GitHub Desktop.
Delete local branches that have been merged into master.
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
| #!/usr/bin/env ruby | |
| branches = %x(git fetch origin && git branch --merged master) | |
| exclude = /master|test|production|staging/ | |
| deletable = branches.split("\n").select { |branch| branch.strip !~ exclude } | |
| if deletable.empty? | |
| puts 'nothing to delete :(' | |
| else | |
| deletable.each { |branch| p %x(git branch -d #{ branch.strip }) } | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment