Git rebase 最终提交不存在。

4

我正在进行一次较长的变基操作,一切进展顺利,直到其中一个 git rebase --continue 的时候,我遇到了以下问题:

$ git rebase --continue
Applying: A git commit
fatal: Unable to create '/Users/me/mycode/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.

我没有删除那个文件,因为它已不存在了。我猜可能是在我重新设置或其他操作时,git GUI程序试图进行刷新。好吧,没关系。我再试一次,但现在出错了。

$ git rebase --continue
fatal: cannot resume: .git/rebase-apply/final-commit does not exist.

确实,它不存在:

$ ls .git/rebase-apply/
0001  0005  0009  0013  0017  0021  abort-safety  last       orig-head          rebasing   threeway
0002  0006  0010  0014  0018  0022  apply-opt     messageid  patch              rewritten  utf8
0003  0007  0011  0015  0019  0023  head-name     next       patch-merge-index  scissors   
0004  0008  0012  0016  0020  0024  keep          onto       quiet              sign    

有没有什么解决这个问题的方法?这是一个长时间的变基操作,所以我不想执行git rebase --abort命令。

1个回答

4

我不知道如何修复您现有的变基问题,但我会采用另一种方法解决:

cp .git/rebase-merge/git-rebase-todo ~/another-folder # backup what is to be done
git branch failed-rebase                              # save the current point as a branch
git rebase --abort

然后,你可以使用以下命令继续失败的变基操作:

git rebase -i --onto failed-rebase <original rebase parameters here>

这将打开编辑器。您应该使用原始的git-rebase-todo文件,使待办事项列表与您最初的意图相匹配。保存文件,退出编辑器,然后重新开始变基。完成后,删除临时分支。


“<original rebase parameters here>”是什么意思? - SarahJessica
1
@SarahJessica 如果你最初使用了 git rebase master 命令,请在第一个 git rebase 调用中使用 master 参数。 - Melebius

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接