git-tips / tips

Most commonly used git tips and tricks.
http://git.io/git-tips
MIT License
21.4k stars 1.71k forks source link

Rebase subtree onto new parent #127

Open srigi opened 8 years ago

srigi commented 8 years ago

Sometimes you made a mistake and want to attach couple of commits to another branch

aa -- bb -- cc -- dd -- ee
 \ -- ff -- gg
git rebase --onto NEW_BASE OLD_BASE
git rebase --onto gg cc
aa -- bb -- cc
 \ -- ff -- gg -- dd -- ee