Created
February 4, 2011 00:45
-
-
Save gaarf/810535 to your computer and use it in GitHub Desktop.
git merge master into all local 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
#!/usr/bin/env ruby | |
BRANCHES = [] | |
`git branch`.each_line do |line| | |
branch = line.gsub(/[^\w]/, '') | |
if line[0]==42 | |
STARTED_ON_BRANCH = branch | |
end | |
BRANCHES << branch | |
end | |
def backtick(command) | |
puts "\n--- $ #{command} ".ljust(80,'-') | |
puts `#{command}` | |
end | |
def confirm(prompt) | |
print "\n***** #{prompt} ? [Y/n] " | |
gets.strip.downcase != 'n' | |
end | |
backtick "git checkout master" | |
backtick "git pull" | |
BRANCHES.each do |branch| | |
unless branch=='master' | |
backtick "git checkout #{branch}" | |
if confirm "merge master into #{branch}" | |
backtick "git merge master" | |
if confirm "push #{branch} to origin" | |
backtick "git push" | |
end | |
end | |
end | |
end | |
backtick "git checkout #{STARTED_ON_BRANCH}" | |
puts "all done!\n\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment