Created
March 15, 2013 07:08
-
-
Save gnufied/5168000 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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