将一系列分支重新设置为并行分支
Rebase a series of branches into parallel Branches
我经常以这样的方式构建一系列分支:
...-(M)
|
+-A
|
+-B
|
+-C
通常对 A、B 和 C 中的每一个都有拉取请求。
问题是,如果我从 C 请求 Pull 请求,它会包含在分支 A 和 B 中所做的所有更改,这只会激怒人们。
我想重新构建图表,使其看起来像:
...-(M)
|
+-A
|
+-B
|
+-C
但每次我尝试将 'B' 或 'C' 变基到“(M)”时,结构都保持不变。
重组它的正确方法是什么?
顺便说一句,我使用 SourceTree 来满足我所有 Git 相关的需求,但很乐意在必要时从控制台指令进行翻译。
编辑:VonC 建议的解决方案确实有效,但是当我使用 Git 的 SourceTree 内置版本时,它对我不起作用。从这里下载便携版后:https://github.com/git-for-windows/git/releases/tag/v2.14.2.windows.3 它工作正常。
任何不涉及 all 先前提交的变基都是 rebase --onto
命令。
git checkout C
git rebase --onto M B C
这意味着:在之后 B(不包括B)到C(包括C)到M.
git checkout B
git rebase --onto M A B
注意:为此,最好使用latest Git for Windows (like PortableGit-2.14.2.3-64-bit.7z.exe
unzipped anywhere you want). That will avoid weird bugs like "There is no tracking information for the current branch. Please specify which branch you want to rebase against." that 的git bash
。
rebase
是本地操作,不应该与远程分支有关。
我经常以这样的方式构建一系列分支:
...-(M)
|
+-A
|
+-B
|
+-C
通常对 A、B 和 C 中的每一个都有拉取请求。
问题是,如果我从 C 请求 Pull 请求,它会包含在分支 A 和 B 中所做的所有更改,这只会激怒人们。
我想重新构建图表,使其看起来像:
...-(M)
|
+-A
|
+-B
|
+-C
但每次我尝试将 'B' 或 'C' 变基到“(M)”时,结构都保持不变。
重组它的正确方法是什么?
顺便说一句,我使用 SourceTree 来满足我所有 Git 相关的需求,但很乐意在必要时从控制台指令进行翻译。
编辑:VonC 建议的解决方案确实有效,但是当我使用 Git 的 SourceTree 内置版本时,它对我不起作用。从这里下载便携版后:https://github.com/git-for-windows/git/releases/tag/v2.14.2.windows.3 它工作正常。
任何不涉及 all 先前提交的变基都是 rebase --onto
命令。
git checkout C
git rebase --onto M B C
这意味着:在之后 B(不包括B)到C(包括C)到M.
git checkout B
git rebase --onto M A B
注意:为此,最好使用latest Git for Windows (like PortableGit-2.14.2.3-64-bit.7z.exe
unzipped anywhere you want). That will avoid weird bugs like "There is no tracking information for the current branch. Please specify which branch you want to rebase against." that git bash
。
rebase
是本地操作,不应该与远程分支有关。