Git: merge only the changes made on the branch

后端 未结 4 1319
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-07 00:38
  G---H             // Release Branch
 /
/
A---B---E---F---    // master
    \\
     \\
      C---D---     // bug fix branch

Based on our particular ne

4条回答
  •  不知归路
    2021-02-07 01:21

    This article advises to instead of merging two branches, you would rebase them where git would only rebase non duplicate commits.

    But instead of cherry-picking, you might consider just rebasing the branch:

    rebase --onto release B bug
    

    where release is the release branch and bug is the bug branch.

    You then get something like

             C'---D' //Bug branch      
            /
           /
      G---H  // Release Branch
     /    
    / 
    A---B---E---F---     // master
    

    But this would mean that when you want the bug fixes to be applied to master that you would need to merge bug with master, which causes all the changes in release also to be added to master.

    It's up to you to decide what works best for you.

    Note that you should not rebase branches that have been pushed to other, because it will create a mess for them.

提交回复
热议问题