Created
July 4, 2012 08:25
-
-
Save pcreux/3046084 to your computer and use it in GitHub Desktop.
delete remote branches behind master
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
| to_delete = [] | |
| branches = `git branch -r | grep origin` | |
| branches.each_line do |branch| | |
| branch.strip! | |
| next if branch['master'] | |
| puts branch | |
| puts cmd = "git diff --stat origin/master...#{branch}" | |
| if `#{cmd}`.empty? | |
| to_delete << branch | |
| end | |
| end | |
| p to_delete | |
| to_delete.each do |br| | |
| br.gsub!("origin/", "") | |
| puts cmd = "git push origin :#{br}" | |
| system cmd | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment