Created
June 22, 2018 13:45
-
-
Save niezbop/fffed1c339d678c419cd23338f7851a5 to your computer and use it in GitHub Desktop.
Stupid script to rename git master branches to git hamster 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
# Tired of typing 'git push origin amster' because you can't avoid typos? | |
# Rename all your master branches to hamster branches! | |
# No more worrying about pesky typos! | |
def bad_usage | |
puts 'Usage ruby git_hamster.rb <PATH> [carrot|stick]' | |
exit -1 | |
end | |
input_args = ARGV | |
if(input_args.length < 1) | |
bad_usage | |
end | |
hamster_mode = true | |
case input_args[1] | |
when 'carrot' | |
hamster_mode = true | |
when 'stick' | |
puts 'Putting the hamster away' | |
hamster_mode = false | |
else | |
bad_usage | |
end | |
origin = hamster_mode ? "master" : "hamster" | |
target = hamster_mode ? "hamster" : "master" | |
Dir.glob("#{input_args[0]}/**/.git/").each do |path| | |
Dir.chdir path do | |
`git branch -m #{origin} #{target}` | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, I was looking for this.