首页 > 解决方案 > 简单的 git rebase 间歇性地需要 --continue 未知原因 -- 可能是什么原因造成的?

问题描述

如果我要进行大量更改,我有时会定期进行“检查点”提交。当我完成我的重大更改时,我git rebase -i习惯将它们全部压缩到一个提交中。我在一个分支上完成这一切,没有合并到 main 或类似的东西,只是git rebase -i为了折叠提交。它几乎总是完美地工作,我已经做了几年了。

但有时它会打嗝,我无法弄清楚为什么。这很少见;我还没有弄清楚发生了什么,所以复制它还不是一种选择。它是这样的:git rebase -i 60a7cc5启动我的编辑器,然后我将提交标记为一起压缩。保存并退出,然后 git 告诉我:

error: Your local changes to the following files would be overwritten by merge:
    ClientApp/Trainer.swift
Please commit your changes or stash them before you merge.
Aborting
hint: Could not execute the todo command
hint: 
hint:     squash 4a98a7f8d482403c6ded9518c4b51cba328e0a8e Interim checkpoint
hint: 
hint: It has been rescheduled; To edit the command before continuing, please
hint: edit the todo list first:
hint: 
hint:     git rebase --edit-todo
hint:     git rebase --continue
Could not apply 4a98a7f... Interim checkpoint

但是ClientApp/Trainer.swift没有被修改——在我开始 rebase 之前,我已经提交了所有内容并且有一个干净的工作树。我做了一个git status,但我没有在任何地方看到该文件,但我得到了这个:

interactive rebase in progress; onto 60a7cc5
Last commands done (4 commands done):
   squash 4a98a7f Interim checkpoint
   squash 997abfa Interim checkpoint
  (see more in file .git/rebase-merge/done)
Next commands to do (2 remaining commands):
   squash 4a98a7f Interim checkpoint
   squash bac5951 Most of the framework is in place; I mean it this time
  (use "git rebase --edit-todo" to view and edit)
You are currently rebasing branch 'main' on '60a7cc5'.
  (all conflicts fixed: run "git rebase --continue")

nothing to commit, working tree clean

请注意它说“所有冲突都已修复”,尽管我没有修复任何东西。我不久前发现,简单地做git rebase --continue会导致变基继续完成,尽管有时它会在不同的提交上反复停止,需要进一步git rebase --continue的 .

这令人担忧,这似乎不是一个正确的工作流程,所以我猜我做错了什么,但我不知道它可能是什么。我已经用谷歌搜索并四处寻找这种问题,但每个人都在用他们的 rebase 做脑部手术。我只是想将一些提交压缩在一起,因此很难找到与我的问题相关的任何内容。

我会就可能导致它的原因寻求建议,下次它发生时我可能会寻找什么,或者因为它最近发生了,我可能会在 reflog 中寻找什么以了解原因,或者其他什么

标签: gitgit-mergegit-rebase

解决方案


推荐阅读