Skip to content

Instantly share code, notes, and snippets.

@derekkraan
Last active December 21, 2015 01:38
Show Gist options
  • Save derekkraan/6228744 to your computer and use it in GitHub Desktop.
Save derekkraan/6228744 to your computer and use it in GitHub Desktop.
Cherry-pick many commits
# cherry-pick many commits
# call with one (optional) argument: the short-hash of the commit in the list that you want to start *after*
# eg:
# $ ruby rebase.rb
# (half of the commits apply, but then you have to fix one manually; the last commit you applied is abc123)
# $ ruby rebase.rb abc123
# (the rest of the commits are cherry-picked)
hashes = ["41ae018", "610f707"]
current_hash = ARGV.first
if current_index = hashes.index(current_hash)
hashes.slice!(0, current_index + 1)
end
hashes.each do |hash|
cmd = "git cherry-pick #{hash}"
puts "> #{cmd}"
exit unless system cmd
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment