Skip to content

Instantly share code, notes, and snippets.

@Rodrigora
Created June 13, 2018 15:28
Show Gist options
  • Save Rodrigora/ffc9f3780ffdfb2fa18b08f815bc91e8 to your computer and use it in GitHub Desktop.
Save Rodrigora/ffc9f3780ffdfb2fa18b08f815bc91e8 to your computer and use it in GitHub Desktop.
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