Skip to content

Instantly share code, notes, and snippets.

@gnufied
Created March 15, 2013 07:08
Show Gist options
  • Save gnufied/5168000 to your computer and use it in GitHub Desktop.
Save gnufied/5168000 to your computer and use it in GitHub Desktop.
desc "Remove branches that are merged to master"
task :grm do
branch_string = `git branch --merged master`
branches = branch_string.strip.split("\n")
branches.each do |branch_name|
branch_name.strip!
unless branch_name =~ /master/
print "Deleting branch #{branch_name} y/n: "
char = STDIN.gets()
if char.is_a?(Fixnum)
if char == 121
system("git branch -D #{branch_name}")
end
else
if char.strip == 'y'
system("git branch -D #{branch_name}")
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment