How to rebase over already rebased branch

 ̄綄美尐妖づ 提交于 2019-12-03 13:27:39

This seems to be a task for the --onto option of git rebase.

git rebase --onto implement_x_rebased implement_x further_bar_fixes_that_depend_on_x

You may want to have look at the --onto example in the git rebase manual.

One way to approach this would be to make implement_x and implement_x_rebased the same first, e.g.:

git checkout implement_x_rebased
git merge implement_x

then merge in your further fixes in the normal way.

The merge of implement_x should be a NOOP from a code point of view (check that git diff implement_x implement_x_rebased actually produces nothing), but you are recording the fact the two are merged, which will allow you to pull over everything else easily.

If they aren't quite the same, you may need the -s ours option. This records that a merge has been done without merging the code. USE WITH EXTREME CAUTION.

Failing that, you can simply use git rebase to rebase the later branches onto implement_x_rebased.

This is better than cherry-picking as a) you don't need to cherry pick each individual commit, remember to get the order right etc. b) semantically, your git tree makes more sense afterwards

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!