如何一次重新设置多个分支? [英] How can I rebase multiple branches at once?

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

问题描述

我目前从事一个使用 SVN 作为存储库的项目.在本地,我对不想提交到 repo 的代码进行了几次实验".因此,我在 SVN 工作目录之上本地使用 git,并为不同的实验"使用多个分支.所以它看起来例如像这样.

I currently work on a project in which SVN is used as a repository. Locally, I do several "experiments" with the code that I don't want to commit to the repo. Therefore I use git locally on top of the SVN working directory and use multiple branches for different "experiments". So it looks e.g. like this.

C0 ---- C7 (master)
 
  ---- C1 ---- C2 ---- C4 (exp1)
               
                ---- C3 (exp2)
          
           ---- C5 (exp3)
       
        ---- C6 (exp4)

在分支 master 我想要未受污染的 SVN repo,即 C0 是 SVN Repo Revision x,C7 是 SVN Repo Revision x + n.

On branch master I want to have the untainted SVN repo, i.e. C0 is SVN Repo Revision x and C7 is SVN Repo Revision x + n.

是否可以轻松地将所有 exp 分支一次重新设置到 C7 上,使树看起来像下图?

Is it somehow easily possible to rebase all the exp branches onto C7 at once in such a way that the tree will look like the following diagram?

C0 ---- C7 (master)
         
          ---- C1' ---- C2' ---- C4' (exp1)
                         
                          ---- C3' (exp2)
                  
                   ---- C5' (exp3)
               
                ---- C6' (exp4)

我想使用 rebase,因为我不想修改本地 SVN Checkout 的状态,并且希望在 SVN 修订版之上构建我的更改.

I want to use rebase since I don't want to modify the state of my local SVN Checkout and want to have my changes built on top of the SVN revisions.

我也对在 SourceTree 中工作而无需使用 shell 的解决方案感兴趣.

I'm also interested in solutions that work from within SourceTree without having to use the shell.

推荐答案

您无法一步到位.充其量你一个一个地移动每个分支;这将是序列:

You can't get this in one step. At best you move each branch one by one; this would be the sequence:

git rebase --onto master exp1
git rebase --onto c2' c2 exp2
git rebase --onto c1' c1 exp3
git rebase --onto master exp4

关键是从旧树中的每个分支点(例如上面的c2)到新树(例如上面的c2')上进行rebase.

The key is to rebase from each branch point in the old tree (e.g. c2 in the above) on to the new tree (e.g. c2' in the above).

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

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