Skip to content

Instantly share code, notes, and snippets.

@niezbop
Created June 22, 2018 13:45
Show Gist options
  • Save niezbop/fffed1c339d678c419cd23338f7851a5 to your computer and use it in GitHub Desktop.
Save niezbop/fffed1c339d678c419cd23338f7851a5 to your computer and use it in GitHub Desktop.
Stupid script to rename git master branches to git hamster branches
# 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
@parasti
Copy link

parasti commented May 3, 2021

Thanks, I was looking for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment