Skip to content

Instantly share code, notes, and snippets.

@michaeleisel
Created November 15, 2019 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaeleisel/fe8947382884d20ee7c63e5c972c6540 to your computer and use it in GitHub Desktop.
Save michaeleisel/fe8947382884d20ee7c63e5c972c6540 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
def try(cmd)
puts cmd
success = system(cmd)
raise unless success
end
def current_commit()
`git rev-parse head`.chomp
end
old_commit = ARGV[0]
raise "usage: `./update.rb <commit you want to update>" unless old_commit
tip = current_commit()
try("git add --all && git checkout #{old_commit} && git commit --amend --no-edit")
new_commit = current_commit()
try("git checkout - && git rebase --onto #{new_commit} #{old_commit}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment