我有这个
* [cf0149e] (HEAD, branch_2) more editing
* [8fcc106] some edit
|
| * [59e643e] (branch_2b) branch 2b
| /
|/
| * [0f4c880] (branch_2_a) branch 2a
| /
|/
* [a74eb2a] checkout 1
* [9a8dd6a] added branch_2 line
|
|
| * [bb903de] (branch_3) branch 3
|/
|
| * [674e08c] (branch_1) commit 1
| * [7d3db01] added branch_1 line
|/
* [328454f] (0.0.0) test
我想将这两者结合起来:
* [a74eb2a] checkout 1
* [9a8dd6a] added branch_2 line
进入一个
* [a74eb2a] This is old [a74eb2a] + [9a8dd6a]
我尝试了更多我想提到的排列:重置,变基,壁球,编辑。似乎无法将其拉下来。每当我成功合并它们时,合并仅存在于一个分支中。例如,“branch_2”将以位于HEAD~2的所需组合结束。但是,“branch_2b”和“branch_2_a”仍然指向我想要合并的两个提交。换句话说,我最终得到了一个新的提交,即两个原始提交的合并。我想要的是让所有分支从这两个提交中出来,现在引用新的合并提交。
答案 0 :(得分:2)
压缩这两个提交之后,你最终将获得一个全新的提交和历史以来的壁球,完全被称为其他东西:
* [cf0149e] (HEAD, branch_2) more editing
* [8fcc106] some edit
|
| * [59e643e] (branch_2b) branch 2b
| /
|/
| * [0f4c880] (branch_2_a) branch 2a
| /
|/
* [a74eb2a] checkout 1
* [9a8dd6a] added branch_2 line
|
| * [cf0149e'] (HEAD', branch_2') more editing (post-squash rebase)
| * [8fcc106'] some edit (post-squash rebase)
| * [SQUASHED] "checkout 1" + "added branch_2 line"
|/
|
| * [bb903de] (branch_3) branch 3
|/
|
| * [674e08c] (branch_1) commit 1
| * [7d3db01] added branch_1 line
|/
* [328454f] (0.0.0) test
请注意,其他现存的分支机构不受影响;那是因为你所做的一切都是一个新的压扁的提交 - 它不会改变其他任何事物的历史。
你的HEAD现在指向cf0149e'
,它将有一个新的SHA1哈希值,因为你已经改变了它的历史记录。
现在,您可以在rebase
上逐个SQUASHED
其他分支,因为这是他们分支的点,以产生:
* [cf0149e] (HEAD, branch_2) more editing
* [8fcc106] some edit
|
| * [59e643e] (branch_2b) branch 2b
| /
|/
| * [0f4c880] (branch_2_a) branch 2a
| /
|/
* [a74eb2a] checkout 1
* [9a8dd6a] added branch_2 line
|
| * [cf0149e'] (HEAD', branch_2') more editing (post-squash rebase)
| * [8fcc106'] some edit (post-squash rebase)
| |
| | * [59e643e] (branch_2b') branch 2b (rebased on SQUASHED)
| | /
| |/
| | * [0f4c880'] (branch_2_a') branch 2a (rebased on SQUASHED)
| | /
| |/
| * [SQUASHED] "checkout 1" + "added branch_2 line"
|/
|
| * [bb903de] (branch_3) branch 3
|/
|
| * [674e08c] (branch_1) commit 1
| * [7d3db01] added branch_1 line
|/
* [328454f] (0.0.0) test
旧历史现在无关紧要,所以我们真的有:
* [cf0149e'] (HEAD', branch_2') more editing (post-squash rebase)
* [8fcc106'] some edit (post-squash rebase)
|
| * [59e643e] (branch_2b') branch 2b (rebased on SQUASHED)
| /
|/
| * [0f4c880'] (branch_2_a') branch 2a (rebased on SQUASHED)
| /
|/
* [SQUASHED] "checkout 1" + "added branch_2 line"
|
| * [bb903de] (branch_3) branch 3
|/
|
| * [674e08c] (branch_1) commit 1
| * [7d3db01] added branch_1 line
|/
* [328454f] (0.0.0) test