Rebase only part of a branch

The actual command would be:

git rebase --onto newbranch1 branch1 branch2

That will replay on top of new_branch1 all commits after branch1 up to branch2 HEAD.

As Joshua Goldberg puts it in the comments:

 git rebase --onto <place-to-put-it> <last-change-that-should-NOT-move> <change to move>

As Denis Sivtsov illustrates in the comments:

If you need only replay the last commit only from branch, in this case work:

git rebase --onto newbranch1 HEAD~1

The solution is considerably simpler than I expected. It turns out that you can supply -i to a much larger variety of rebase commands (I thought it was only for rebasing a branch to itself for changing history). So I simply ran git rebase -i master and dropped those extra commits.

Tags:

Git