Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 交互式重基在尝试挤压提交后不断添加步骤_Git - Fatal编程技术网

Git 交互式重基在尝试挤压提交后不断添加步骤

Git 交互式重基在尝试挤压提交后不断添加步骤,git,Git,当我的分支在自身上重定基址,以便通过将它们挤压在一起来清理提交时,我的重定基址陷入了一个循环中,不知道如何打破这个循环。这适用于我所从事的每一个分支,而不仅仅是一个分支 例如,假设我有一个分支,我的分支有三个提交 commit 1 commit 2 commit 3 在我的终端中,我写git-rebase-I-origin我的分支 这让我想到了交互式git,在我关于Sublime文本的例子中 在这里,我看到了我的所有提交,并将最后一个更改为挤压,以便我只有提交1和2: p commit 1 p

当我的分支在自身上重定基址,以便通过将它们挤压在一起来清理提交时,我的重定基址陷入了一个循环中,不知道如何打破这个循环。这适用于我所从事的每一个分支,而不仅仅是一个分支

例如,假设我有一个分支,我的分支有三个提交

commit 1
commit 2
commit 3
在我的终端中,我写git-rebase-I-origin我的分支

这让我想到了交互式git,在我关于Sublime文本的例子中

在这里,我看到了我的所有提交,并将最后一个更改为挤压,以便我只有提交1和2:

p commit 1
p commit 2
s commit 3
从这里,我看到了另一个交互式窗口,在该窗口中,我删除了提交3的提交消息,只留下提交2

这一切似乎都是工作,但现在我陷入了一个循环

例如,在我的终端上,它处于重新基准步骤3/3,然后我进行重新基准-继续,继续到步骤4/4,没有任何更改重新基准-再次继续步骤5/5,依此类推,而不实际离开重新基准


我被迫使用rebase-abort,并且我的提交没有挤压。

如果您想挤压到最后的rebase,您可以跳过使用rebase-I,并使用以下技巧:

git checkout my-feature
git merge master # merge with the branch you want to rebase onto
# don't worry, that will go away with the following steps
git reset --soft master # move branch pointer to master, all changes between your branch and master (theoretically speaking, all changes related to your feature _only_ will be in index
git commit -m "My feature"

就这样。

按照您概述的一般程序,我无法重现您描述的行为。具体地说,在保存并退出提交消息的第二个编辑器后,重基将按其应该的方式完成。如果您可以发布一个以这种方式运行的rebase会话的准确副本,这可能会有所帮助您使用的是什么版本的Git?我非常模糊地记得在一些古老的Git中有这样一个bug,比如2.3或者其他什么。我想就是这样,实际上是在使用Git版本2.27