Created
June 13, 2018 15:28
-
-
Save Rodrigora/ffc9f3780ffdfb2fa18b08f815bc91e8 to your computer and use it in GitHub Desktop.
Ruby script to delete 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
def delete_branches | |
pattern = /CT-\d{4}/ | |
result = `git branch` | |
branches = result.split("\n").map(&:strip) | |
branches.each do |branch| | |
if branch =~ pattern | |
puts `git branch -d #{branch}` | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment