将git分支分成两个分支? [英] Split a git branch into two branches?

查看:147
本文介绍了将git分支分成两个分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图帮助一位同事从另一个功能分支意外创建了一个功能分支,而不是从主分支创建第二个功能分支。这里基本上是我们现在所拥有的......

 大师--- A --- B --- C 
\\ \\
Foo E --- F --- F --- H
\
Bar J --- K --- L --- M

这就是我们想要的...

 大师--- A --- B --- C 
| \
Foo | E --- F --- F --- H
|
Bar J --- K --- L --- M

想到的是创建FooV2和BarV2分支,然后樱桃挑选单个提交到适当的V2分支。但我很好奇,是否有更好的方法来处理这种情况?

解决方案

它看起来像我可以:

  git checkout J 
git rebase master

编辑:

我尝试了我的建议,但不起作用。 knittl的建议不起作用(在我的盒子里)。这是什么为我工作:

  git rebase --onto master foo bar 


I'm trying to help out a coworker who accidentally created one feature branch from another feature branch, rather than creating the second one from master. Here is essentially what we have now…

Master ---A---B---C
                   \
              Foo   E---F---F---H
                                 \
                            Bar   J---K---L---M

And here is what we'd like to have…

Master ---A---B---C
                  |\
             Foo  | E---F---F---H
                  |
             Bar  J---K---L---M

One way I thought of would be to create FooV2 and BarV2 branches, and cherry-pick the individual commits into the appropriate V2 branches. But I'm curious, is there a better way to handle this situation?

解决方案

It looks to me like you could:

git checkout J
git rebase master

Edit:

I tried what I suggested and it doesn't work. knittl's suggestion doesn't work (on my box). Here's what did work for me:

git rebase --onto master foo bar

这篇关于将git分支分成两个分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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