git 如果 --abort 不起作用,如何中止交互式变基?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5104649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 10:12:14  来源:igfitidea点击:

How to abort an interactive rebase if --abort doesn't work?

gitexitrebaseabortquit

提问by mjs

I've got myself into a muddle via an interactive rebase, and I now wish to abort it. (i.e. go back to the point before I was dropped into interactive rebase mode, in my case via git pull --rebase.) The way to do this seems to be via git rebase --abort, but this doesn't work:

我已经通过交互式 rebase 陷入了混乱,现在我想中止它。(即回到我进入交互式 rebase 模式之前的那一点,在我的情况下是 via git pull --rebase。)这样做的方法似乎是 via git rebase --abort,但这不起作用:

$ git rebase --abort
error: Ref refs/heads/master is at 55b388c141b1485b1acd9e050dbeb0eb90ef2ee7 but
expected b918ac16a33881ce00799bea63d9c23bf7022d67
fatal: Cannot lock the ref 'refs/heads/master'.
Could not move back to refs/heads/master

How can I get out of interactive rebase mode, and clean up all references to it? (git reset --hardsucceeds, but doesn't drop me out of rebase mode.)

如何退出交互式 rebase 模式,并清除对它的所有引用?(git reset --hard成功,但不会让我退出 rebase 模式。)

采纳答案by P Shved

Try to follow the advice you see on the screen, and first reset your master's HEAD to the commit it expects.

尝试遵循您在屏幕上看到的建议,并首先将您的 master 的 HEAD 重置为它期望的提交。

git update-ref refs/heads/master b918ac16a33881ce00799bea63d9c23bf7022d67

Then, abort the rebase again.

然后,再次中止变基。