Git: merge only the changes made on the branch

后端 未结 4 1336
爱一瞬间的悲伤
爱一瞬间的悲伤 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:24

    Create a patch file containing the unique content from the bugfix branch. Then apply that patch file to the release branch.

    Example:

    > git checkout bugfix_branch
    > git diff B HEAD > unique_changes.patch /* where "B" is the point where bugfix_branch split from dev */
    > git checkout release_branch
    > git apply unique_changes.patch
    

    Et voila! You now have only the unique changes from the bugfix branch in your release branch. Note that format-patch tends to more gracefully handle situations where files have been moved or deleted, so you may need to play around with the actual process by which the patch is generated, but this approach should get you close.

提交回复
热议问题