Created
October 17, 2018 21:52
-
-
Save Kallin/bdbbba6edb07b6e906864159ef9184b8 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
current_branch = `git symbolic-ref --short HEAD`.chomp | |
if current_branch != "master" | |
if $?.exitstatus == 0 | |
puts "WARNING: You are on branch #{current_branch}, NOT master." | |
else | |
puts "WARNING: You are not on a branch" | |
end | |
puts | |
end | |
local_branches= `git branch --merged`. | |
gsub(/^\* /, ''). | |
split("\n"). | |
map(&:strip). | |
reject {|b| b =~ /(#{current_branch}|master)/} | |
if local_branches.empty? | |
puts "No existing branches have been merged into #{current_branch}." | |
else | |
puts "This will remove the following branches:" | |
puts local_branches.join("\n") | |
puts "Proceed?" | |
if gets =~ /^y/i | |
`git branch -d #{local_branches.join(' ')}` | |
else | |
puts "No branches removed." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment