Git rebase branch with merged children

后端 未结 2 1097
太阳男子
太阳男子 2021-02-07 15:54

Today I faced with one problem. My teammate created branch from master. He developed one feature in this branch and after that developed two subfeatures in subfeature\'s branche

2条回答
  •  一向
    一向 (楼主)
    2021-02-07 16:28

    Note that you need a git1.7.6+ for git rebase --preserve-merges to work properly.

    • a rebase --preserve-merges --onto didn't work before ("git rebase --preserve-merges --onto doesn't preserve merges")
    • a rebase --preserve-merges had issue in some instance:
      • see this thread, when both sides of the merge are replayed)
      • "Git: Rebasing Merge Commits " (post from Alexandru Pasca)

    Long story short: You just completed a merge and somebody has pushed a commit before you were able to push yours. The solution is to make git aware of the merge you did.

    git rebase --preserve-merges 
    

    or

    git rebase -p 
    

    But there's a problem, if your merge had conflicts that you solved they won't be picked up by the rebase machinery.
    And you will end up resolving the conflicts again ... at least this is the case with git version 1.7.5.4

    (That would call for git rerere)

提交回复
热议问题