2

On the git man page for rebase you can find one example for rebasing branches.

                        H---I---J topicB
                       /
              E---F---G  topicA
             /
A---B---C---D  master

The command git rebase --onto master topicA topicB would yield ...

             H'--I'--J'  topicB
            /
            | E---F---G  topicA
            |/
A---B---C---D  master

... which is quite reasonable as far as I understand rebasing. Unfortunately the next example shows a different output. Basically it describes how rebasing can be used to remove commits:

E---F---G---H---I---J  topicA

According to the man page calling git rebase --onto topicA~5 topicA~3 topicA would yield ...

E---H'---I'---J'  topicA

..., and thus, "remove F and G".

But actually I don't see a big difference between the first and the second example:

        H---I topicA
       /
  F---G topicA~3
 /
E topicA~5

So the result should be more like

 H'--I'--J'  topicB
/
| F---G  
|/
E

Are F and G still there or are they really removed? At least gitk shows me F and G and even H, I and J. Are this unreachable commits? Will they be "garbage-collected" after some time? Or will there be forever on my disk (even pushed to a remote). Can this be applied on the first example as well? Are H, I and J still there?

4

2 回答 2

2

它们没有被删除,提交仍然存在,如果您知道提交,您可以检查它们、标记它们、创建分支等。 git reflog 命令可以帮助找到它们。

如果没有任何东西涉及它们,它们最终将被垃圾收集。页面会告诉您更多相关信息。默认情况下是 90 天之后。

于 2013-04-24T13:52:31.247 回答
1

之后原件E---F---G---H---I---J还在。变基不能改变任何东西。认为它更像是为 rebase 下的每个提交生成一个补丁,然后将其应用于正在创建的新分支。F并且G没有被删除;从Gto的变化H在. 然后从to的变化在新的创造之上重播。最后,分支——只是一个指针——被重新指向,原来的分支从视图中消失了,因为现在没有任何东西指向它的任何部分。EH'HIH'I'J'

于 2013-04-24T16:39:43.460 回答