If you have changes on a branch which you want to apply to another branch which has a different history you might not want to merge or rebase. This method allows you to identify a series of commits and replay them onto your destination branch. For instance:
- You have your
master
branch which you want to apply some commits from another branch -menu-test
-
master
andmenu-test
have diverged so you just want a portion of the commits on that branch
- Checkout a new temporary branch from the top of the destination branch
master
a.git checkout master
b.git checkout -b destination
- Move the
mater
branch pinter to the last commit in the series you want to apply
a.git branch -f master [sha of last commit]
- Rebase the patchset onto
destination
a.git rebase --onto destination [sha of commit before first commit] master
This replays (rebases) the commits after the given sha up to the master
reference onto the destination
branch. You may have conflicts from the process you'll need to deal with as normal.
Note to self: I need to think more about the branches referenced, there's a simpler way to do this without creating branches and stuff, I'm sure.
Posted by adre to Foxsoft (2018-01-24 17:27)