Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby script to delete git branches
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