git rebase 和删除的 rebase 分支导致“交互式 rebase 已经启动”错误消息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8895915/
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 12:45:24  来源:igfitidea点击:

git rebase and deleted rebasing branches causing "Interactive rebase already started" error message

gitrebase

提问by tee

I was trying something out with a couple of branches so I rebased on a temporary branch and was in the middle of resolving some conflicts when I decided to not to complete the rebase it out another way. I then deleted the temporary branch involved and went on my merry way. A couple of hours later I wanted to rebase another branch and get this error message

我正在用几个分支尝试一些东西,所以我重新建立了一个临时分支,当我决定不以另一种方式完成重新建立时,我正在解决一些冲突。然后我删除了涉及的临时分支并继续我的快乐之路。几个小时后,我想重新设置另一个分支并收到此错误消息

Interactive rebase already started

git rebase --abortdisplays this error message

git rebase --abort显示此错误消息

error: unable to resolve reference refs/heads/tmp/rails3-rails-2-fixes: No such file or directory
fatal: Cannot lock the ref 'refs/heads/tmp/rails3-rails-2-fixes'.
Could not move back to refs/heads/tmp/rails3-rails-2-fixes

Tried to just create another branch named tmp/rails3-rails-2-fixesbut no dice

试图创建另一个名为tmp/rails3-rails-2-fixes但没有骰子的分支

Any ideas how I can resolve this?

有什么想法可以解决这个问题吗?

采纳答案by Cascabel

Hm, that's awkward. Recreating the branch would've been my first try too. Failing that, you should be able to remove the .git/rebase-mergedirectory, which contains the rebase state. (Move it to the side instead to be safe, if you want.) Once that's gone, Git shouldn't have any way to know there was a rebase in progress. Have a look at your branches to make sure you haven't managed to lose any commits in the process, and you'll be good!

嗯,这很尴尬。重新创建分支也是我的第一次尝试。否则,您应该能够删除.git/rebase-merge包含 rebase 状态的目录。(为了安全起见,如果你愿意,可以把它移到一边。)一旦它消失了,Git 就不应该知道有一个正在进行的变基。看看你的分支,确保你没有在这个过程中丢失任何提交,你会很好!

回答by Dau

check the git statusand see if you not checkout any branch after last rebase then you are not on any branch.

检查git status并查看您是否在上次变基后未结帐任何分支,那么您不在任何分支上。

becase rebase transfer you to a non branch area, so you have to abort the last rebase by using git rebase --abortcommand and checkout a branch to go on the branch and start new rebasing

因为rebase将您转移到非分支区域,因此您必须使用git rebase --abort命令中止最后一个rebase并签出分支以继续该分支并开始新的rebase

回答by Eliot

I just got a very similar error during an attempted rebase that did not fail. None of the tips above helped. Here's what I was seeing:

我刚刚在尝试 rebase 时遇到了一个非常相似的错误,但没有失败。上面的提示都没有帮助。这是我所看到的:

$ git pull --rebase
warning: refname 'xport1' is ambiguous.
First, rewinding head to replay your work on top of it...
Fast-forwarded xport1 to 98b787b0ea1f7f6771a5b1b56c7e8cc67b84c242.
error: Ref refs/heads/xport1 is at 98b787b0ea1f7f6771a5b1b56c7e8cc67b84c242 but expected 3865d63ffb3a1a495363bfbd9ebb089e16152839
fatal: Cannot lock the ref 'refs/heads/xport1'.
Could not move back to refs/heads/xport1

It turns out that if a reference name is ambigious, the rebase will fail, at least on git version 1.7.10.2 (Apple Git-33). I poked around and saw I had accidentally created a tag with the same name as the branch I was trying to rebase on. Deleting the tag got rid of this error.

事实证明,如果引用名称不明确,则 rebase 将失败,至少在 git version 上1.7.10.2 (Apple Git-33)。我四处看看,发现我不小心创建了一个与我试图重新建立的分支同名的标签。删除标签摆脱了这个错误。