Git 变基最终提交不存在

Git rebase final-commit does not exist

我正处于一个长期的变基过程中,一切都很顺利,直到我的 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

我不知道如何修复你现有的变基,但我会通过做另一个来解决:

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 文件使待办事项列表与您最初的意图相匹配。保存文件,退出编辑器,rebase 将开始。完成后,删除临时分支。