I would like to rebase a given commit to be HEAD of my current branch. Of course I can use git rebase -i <future-head-SHA>~
and then move it down to HEAD (as described in this question), but I want to automate this process.
Is there a neat way to do this?
Thanks
Not really. Interactive rebase is the only tool designed to do this kind of thing. You could, hypothetically, script this, though:
rebase -i
instructions from the file passed as its first argument - the file you'd normally get to edit yourself in an editor -, and writes a re-ordered list back into that file.The following should work, provided you have GNU sed installed (other editions of sed usually don't support the
-i
flag):