Skip to content

Instantly share code, notes, and snippets.

@iorionda
Created April 1, 2013 05:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iorionda/5283396 to your computer and use it in GitHub Desktop.
Save iorionda/5283396 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'optparse'
opts = OptionParser.new
opts.on('--noop', 'dry-run mode') { |v| $noop = true }
opts.parse!
`git branch -r`.each_line do |branch|
branch.strip!.chomp!
next if branch =~ %r![^/]+/master!
next if branch =~ %r![^/]+/develop!
if `git branch --contains #{branch}`.each_line.any? { |included| included.strip.chomp =~ /\A[* ]*(develop|master)\z/ }
ref = branch.sub(%r!^([^/]+)/!, '')
command = "git push --delete #{$1}/#{ref}"
puts command
unless $noop
system command
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment