在多个分支做一个git樱桃选择 [英] do a git cherry-pick in multiple branches

查看:111
本文介绍了在多个分支做一个git樱桃选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候我有这样的情况:我发现
有错误并纠正错误,然后进行修改。
这个提交可以在所有受影响的
分支中挑选出来,这是我非常喜欢的一个功能。

但事实证明,检查受影响的
5-10分支,挑选提交)或容易出错(在分支上工作时选择
- 有时几天/几周后)

是否有可能将樱桃选择
自动化为多个分支?
编写一个迭代受影响分支的脚本似乎是可能的,
但受影响的分支集合(以及分支本身)
永久变化 -

Best
Wendy

解决方案

短版答案:你不应该选择这个错误修正。你应该合并它。所有你需要做的就是确保你将修复提交给从需要修复的所有分支的共同祖先开始的分支,然后将它合并到它们中的每一个中。这比挑选樱桃更好,因为它不会在你的回购中重复提交,如果你以后需要合并两个收到修复的分支,就不会有问题。这里的一般原则是一个维护分支,从您维护的一些旧版本开始,并从那里合并到所有后来维护的版本和版本中。



更多详细信息,以及相关的哲学建议,请参阅我对这个问题的回答关于采摘樱桃,以及评论和我在这些评论中提供的链接!


sometimes i have the situation that i discover a bug and correct it and then commit the changes. This commit can be cherry-picked in all affected branches, a feature that i really like.

But it turns out to be tedious ( check out affected 5-10 branches, pick commit ) or error-prone ( cherry-picking when working on that branch - sometimes days/weeks later )

Is there a possibility to automate the cherry-picking into multiple branches? Writing a script iterating the affected branches seems possible, but the set of affected branches ( and the branches themselves ) changes permanently -

Best Wendy

解决方案

Short version of the answer: you should not cherry-pick this bugfix. You should merge it. All you need to do is make sure you commit the fix to a branch started from a common ancestor of all branches which need the fix, and then merge it into each of them. This is much better than cherry-picking, because it doesn't make duplicate commits all over your repo, and if you later need to merge two of the branches which received the fix, there won't be problems. The general principle here is a maintenance branch, started from some older version which you're maintaining, and merged from there into all later maintained versions and releases.

For more detail, and related philosophical advice, see my answer to this question about cherry-picking, as well as the comments to it and the links I supplied in those comments!

这篇关于在多个分支做一个git樱桃选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆