Created
October 8, 2015 18:26
-
-
Save oggy/cf24933ff8f194912240 to your computer and use it in GitHub Desktop.
Command to delete git branches that have been merged into the current branch
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 | |
keep = `git config git-delete-merged-branches.persist`.strip.split(',') | |
puts "preserving: #{keep.join(', ')}" | |
current_branch = `git rev-parse --abbrev-ref HEAD`.strip | |
`git branch --merged`.lines.each do |line| | |
next if line =~ /\A\* / | |
branch, target = line.strip.split(' -> ', 2) | |
next if keep.include?(branch) || keep.include?(target) | |
system 'git', 'branch', '-d', branch | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment