如何重新调整已经重新设计的分支 [英] How to rebase over already rebased branch

查看:111
本文介绍了如何重新调整已经重新设计的分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的git分支是这样的:

  master  -  *  -  *  -  *  -  *  -  *  -  *  -  implement _x 
\\ - * - further_foo_fixes_that_depend_on_x
\ \ - * - * - further_bar_fixes_that_depend_on_x
\
\-implement_x_rebased

它以这种方式结束,因为我认为我的分支 implement _x 会按原样合并到上游,但是我被要求将它压缩到一个提交,因此 implement _x_rebased 。但是,在等待 implement _x 进行合并时,我已经开始了几个分支机构,以进一步修复和开发依赖于我的工作。



现在我想重新进一步研究 implement _x_rebased 的工作。因为 implements_x implements_x_rebased 处于完全相同的状态,所以我认为这是一个no-op,合并冲突,只需在实施_x further_foo_fixes_that_depend_on_x 之间应用 / code>。然而,看起来git并不那么聪明,并且它试图从基础开始重新绑定 - 引入不必要的合并冲突。



我认为简单的方法out是rebase&打破 implements_x 的进一步修复,然后存储它们,并将这些存储应用于 implement _x_rebased ,但是我'm好奇是否有任何正确的方法让git认识到 implements_x implements_x_rebased 实际上处于相同的状态?

解决方案

这似乎是 - 到选项的任务 git rebase

  git rebase --onto implements_x_rebased implement _x further_bar_fixes_that_depend_on_x 

您可能希望查看 - 到 git rebase手册中的示例。


My git branches look like this:

master-*-*-*-*-*-*-implement_x
 \                    \-*-further_foo_fixes_that_depend_on_x
  \                    \-*-*-further_bar_fixes_that_depend_on_x
   \
    \-implement_x_rebased

It ended this way, because I thought my branch implement_x would be merged upstream as it is, but I was asked to squash it to a single commit, thus implement_x_rebased. However, I already started several branches for further fixing and developing that depend on my work, while waiting for the implement_x to get merged.

Now I'd like to rebase the further work on implement_x_rebased. I thought this was a no-op, since implement_x and implement_x_rebased were in the exactly same state - there would be no merge conflicts, just applying the changes between implement_x and further_foo_fixes_that_depend_on_x etc. on top of implement_x_rebased. However, it seems that git isn't that smart, and it tries to rebase all the way from the base - introducing needless merge conflicts.

I thought that the easy way out is rebase&squash the further fixes on implement_x and then stash them, and apply the stashes to implement_x_rebased, but I'm curious whether there is any proper way to make git realise that implement_x and implement_x_rebased are actually in the same state?

解决方案

This seems to be a task for the --onto option of git rebase.

git rebase --onto implement_x_rebased implement_x further_bar_fixes_that_depend_on_x

You may want to have look at the --onto example in the git rebase manual.

这篇关于如何重新调整已经重新设计的分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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