择优挑选与变基
以下是我经常遇到的场景:
您在 master
或 design
上有一组提交,我想将其放在 生产
之上分支。
我倾向于创建一个以 生产
为基础的新分支,在其上挑选这些提交并将其合并到 生产
然后当我合并 master
时在生产中,我面临合并冲突,因为即使更改是相同的,但由于樱桃选择而被注册为不同的提交。
我找到了一些解决方法来解决这个问题,所有这些方法都很费力,可以称为“黑客”。
尽管我没有做太多的变基,但我相信这也会创建一个新的提交哈希。
我应该在我挑选的地方使用变基吗?与此相比,它还有哪些优点呢?
The following is a scenario I commonly face:
You have a set of commits on master
or design
, that I want to put on top of production
branch.
I tend to create a new branch with the base as production
cherry-pick these commits on it and merge it to production
Then when I merge master
to production, I face merge conflicts because even tho the changes are same, but are registered as a different commit because of cherry-pick.
I have found some workarounds to deal with this, all of which are laborious and can be termed "hacks".
Altho' I haven't done too much rebasing, I believe that too creates a new commit hash.
Should I be using rebasing where I am cherrypicking. What other advantages does that have over this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该在生产之上创建一个
rebase --interactive
设计分支,其中:需要将 x1 和 x2 包含在生产中:
然后:
这允许您:
Lakshman Prasad 添加:
我会做同样的事情,但是使用仅为操作创建的私有分支:
,然后是变基,这次使用私有分支(即你永远不会推送的分支)。
那么:
master 不会从提交重新排序中受益(具有更符合逻辑的顺序),但至少您可以随时推送 master 。
并且
生产
仍然可以准确地包含它所需要的内容。如果后续对
master
的提交有相同的问题(有些需要包含在生产
中,其他的稍后会包含在内),我会:master-private
> (我们并不真正关心那些 x',来自 master 的 x 提交的副本)master-private
分支,rebase --interactive
code>,采用粗略的冲突解决策略(除了该master-private
分支的第一次提交,因为这些提交需要集成到生产
分支中)You should make a
rebase --interactive
your design branch on top of production, where:With x1 and x2 needing to be included in production:
Then:
That allows you:
Lakshman Prasad adds:
I would do the same, but with a private branch created just for the operation:
, then the rebase, this time with the private branch (i.e. a branch you won't ever push).
Then:
master
won't benefit from the commit reordering (with a more logical order), but at least you can pushmaster
whenever you want.And
production
can still include exactly what it needs.If subsequent commits to
master
have the same issue (some need to be included toproduction
, other will later), I would:master-private
(we don't really care about those x', copy of x commits from master)master-private
branch on top of masterrebase --interactive
, with a crude conflict resolution tactic (except for the first commits of thatmaster-private
branch, since those ones need to be integrated in theproduction
branch)