Created
April 4, 2018 04:20
-
-
Save bacrossland/d1fc52776eb709dffaac3e2da9127e69 to your computer and use it in GitHub Desktop.
Ruby script for removing old local and remote git branches
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/ruby | |
branches = `git branch --list ` | |
branches.gsub!('\n') | |
branches_arr = branches.split | |
# Removing from the branches_arr the branches you want to keep. | |
# Add or remove branches from here based on your need. | |
branches_arr.delete('*') | |
branches_arr.delete('development') | |
branches_arr.delete('master') | |
branches_arr.each do |b| | |
`git branch -d #{b}` | |
`git push origin --delete #{b}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment