Skip to content

Instantly share code, notes, and snippets.

@sideshowbandana
Last active August 29, 2015 14:17
Show Gist options
  • Save sideshowbandana/8cfdb24ad2cda5107771 to your computer and use it in GitHub Desktop.
Save sideshowbandana/8cfdb24ad2cda5107771 to your computer and use it in GitHub Desktop.
reap merged git branches
STDOUT.write "remote: "
remote = gets.chomp
def run(str)
puts str
puts `#{str}`
end
`git branch -r --merged`.gsub(" ", "").split("\n").select{ |a| a =~ /^#{remote}/ }.each{ |branch|
run "git push #{remote} --delete #{branch.gsub("#{remote}/", "")}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment