How to move bugfixes across branches in DVCS?

后端 未结 3 961
名媛妹妹
名媛妹妹 2020-12-06 18:16

If we discover bug in some branche we fix it (check New release on picture). But also we interesting in moving this fix to Old release and Main de

相关标签:
3条回答
  • 2020-12-06 18:53

    You could:

    1. Find common parent. Thanks to Novelocrat for this step.
      git merge-base branch1 branch2 branch3 ...

    2. Checkout the common parent
      git checkout A

    3. create new branch to fix bugs on
      git checkout -b bugFix

    4. Make bug fixes and commit them to bugFix branch

    5. Checkout branch that needs the bug fix
      git checkout branchToApplyFixTo

    6. Merge the bugFix into the branch
      git merge bugFix

    0 讨论(0)
  • 2020-12-06 19:01

    You could git cherry-pick bugfix on each affected branch that you want to fix. This would generate a new commit id for the fix on each branch, though.

    0 讨论(0)
  • 2020-12-06 19:07

    This why people make separate branches for each feature or bug fix. Then the only trick is to make sure when you create the branch, it is from a point that excludes any commits you wouldn't want included in every branch you intend to merge back into. If you forget, you can just rebase it to that point before doing any merges. If you don't catch it until after it's merged back into your new release branch as shown in your example, the best option is probably cherry picking, although that can make future merges very difficult if you use it too often.

    0 讨论(0)
提交回复
热议问题