重新包含所有子项目的分支 [英] Rebasing a branch including all its children

查看:129
本文介绍了重新包含所有子项目的分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的Git存储库拓扑结构:

  ABF(master)
\ D(feature-a )
$ /
C(功能)
\
E(功能-b)

通过重新定义特性分支,我期望重新绑定整个子树(包括子分支):

$ $ p $ code $ git rebase feature master

ABF(master)
\ D(feature-a)
\ /
C(功能)
\
E(功能-b)

然而,这是实际结果:

  C'(feature)
/
(功能-a)
\ /
C
\
E(功能-b)

我知道我可以通过执行以下操作轻松修复它:

  $ git rebase --onto特性C特性-a 
$ git rebase - 特性C特性eb

但是有没有办法自动重新分支分支,包括所有的子/后裔?

解决方案

  git branch --contains C | \ 
xargs -n 1 \
git rebase --committer-date-is-author-date --preserve-merges --onto BC ^


I have the following Git repository topology:

A-B-F (master)
   \   D (feature-a)
    \ /
     C (feature)
      \
       E (feature-b)

By rebasing feature branch I expected to rebase the whole subtree (including child branches):

$ git rebase feature master

A-B-F (master)
     \   D (feature-a)
      \ /
       C (feature)
        \
         E (feature-b)

However, this is the actual result:

      C' (feature)
     /
A-B-F (master)
   \   D (feature-a)
    \ /
     C
      \
       E (feature-b)

I know I can easily fix it manually by executing:

$ git rebase --onto feature C feature-a
$ git rebase --onto feature C feature-b

But is there a way to automatically rebase branch including all its children/descendants?

解决方案

git branch --contains C | \
xargs -n 1 \
git rebase --committer-date-is-author-date --preserve-merges --onto B C^

这篇关于重新包含所有子项目的分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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