#!/usr/bin/env ruby target_branch = ARGV[0]&.strip if target_branch.nil? || target_branch.empty? puts "You must provide a target branch name!" exit 1 end current_branch = `git rev-parse --abbrev-ref HEAD`.strip branch_to_merge = current_branch puts "Running git pull origin #{current_branch} --rebase\n\n" `git checkout #{target_branch}` `git pull origin #{target_branch} --rebase` puts "\nRebasing #{target_branch} into #{branch_to_merge}\n\n" `git checkout #{branch_to_merge}` `git rebase #{target_branch}` puts "\nForce pushing #{branch_to_merge}\n\n" `git push origin #{branch_to_merge} -f` puts "\nCompleting the merge of #{branch_to_merge} into #{target_branch}\n\n" `git checkout #{target_branch}` `git merge #{branch_to_merge} --no-ff --no-edit` puts "\nMerge complete, you must run git push origin #{target_branch} manually to complete the merge\n"