-
-
Save andiskiy/9893207e8aaa928535f8965f2cf043b5 to your computer and use it in GitHub Desktop.
Ruby script for removing old local and remote git branches
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
#!/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