Skip to content

Instantly share code, notes, and snippets.

@teamon
Last active December 13, 2015 23:59
Show Gist options
  • Save teamon/4995316 to your computer and use it in GitHub Desktop.
Save teamon/4995316 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
def sh(cmd)
puts "[sh] #{cmd}"
raise "git error" unless system(cmd)
end
if ARGV.size < 3 || ARGV[1] != "of"
puts "Example usage: git make staging of dev feature/foo feature/bar"
else
dpl = ARGV[0]
base = ARGV[2]
rest = ARGV.drop(3)
print "Warning!! This will delete branch #{dpl} ! (Hit enter to continue or Ctrl-C to cancel)"
STDIN.gets
sh "git checkout #{base}"
sh "git branch -D #{dpl}"
sh "git checkout -b #{dpl}"
rest.each {|r| sh "git merge #{r}" }
sh "git push -f origin #{dpl}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment