fatal:Could not open file .git/rebase-merge/done for阅读:No such file or directory

2ekbmq32  于 12个月前  发布在  Git
关注(0)|答案(6)|浏览(196)

我本来想做一个变基来删除我的最后一次提交,但我不想完成,所以我退出了。(我意识到这可能不是最好的方法,但它的完成)我想我做错了,因为我得到的错误:fatal: Could not open file .git/rebase-merge/done for reading: No such file or directory每次运行git status。我如何摆脱这个错误,以便我可以继续提交?我能直接删除文件吗?如果我能删除它,我会怎么做?

brccelvz

brccelvz1#

在您尝试以下操作之前,请确保您先stashcommit任何未提交的更改,否则您将无法挽回地丢失它们。
然后试着做一个git rebase --abort

gcuhipw9

gcuhipw92#

Stash或commit对我不起作用,我只是创建了git抱怨的文件,直到它起作用!

$ git rebase --abort
error: could not read '.git/rebase-apply/head-name': No such file or directory

echo "master" > .git/rebase-apply/head-name

$ git rebase --abort
error: could not read '.git/rebase-apply/onto': No such file or directory

$ echo "develop" > .git/rebase-apply/onto

$ git rebase --abort
error: could not read '.git/rebase-apply/head': No such file or directory

$ echo "develop" > .git/rebase-apply/head

在此之后,git rebase --abort工作。您在这些文件中放置的分支名称必须存在,在我的例子中,我不关心我的本地更改,但如果您这样做,显然要小心。

0qx6xfy6

0qx6xfy63#

DavidN的解决方案中止rebase是伟大只要你没有任何unstaged的变化,因为最后一个rebase去南方!
如果在尝试变基后编写代码,忽略could not open file .git/rebase-merge/done消息,
那你最好的办法就是

git stash

保存本地更改,然后才中止变基。
我确信这是一个stackoverflow问题,那些急于解决问题而不考虑其含义的人,只会运行abort命令,并很快后悔。

wkyowqbh

wkyowqbh4#

我刚刚做了:

git add .
git commit -m "change inter rebase"

然后可以继续:

git rebase --continue

没有

git stash 
git rebase --abort

needed.

bhmjp9jg

bhmjp9jg5#

对于在Visual Studio Code中执行此操作的人,请关闭正在运行的终端/shell,然后运行git rebase --quit
这样做将解决这个问题。

ktca8awb

ktca8awb6#

错误信息现在应该更清楚了:

error: you have staged changes in your working tree

(因此使用add+commit或stash)
Git 2.43(Q4 2023)修复了“rebase -i“在命令被冲突更改中断时的行为。
参见commit 203573bcommit 405509ccommit e032abdcommit f2b5f41commit 9f67899commit 206a78dcommit 36ac861(2023年9月6日)至Phillip Wood ( phillipwood )
(由Junio C Hamano -- gitster --合并于commit b995e78,2023年9月14日)

rebase --continue:命令失败后拒绝提交

签字人:菲利普·伍德
如果一个提交因为会覆盖一个未被跟踪的文件而不能被选择,那么“git rebase --continue”(man)应该拒绝提交任何阶段性的更改,因为这个提交没有被选择。
这是通过在消息文件丢失时拒绝提交来实现的。
选择消息文件进行此检查是因为只有在“git rebase”(man)停止以供用户解决合并冲突时才写入该文件。
现有的命令在继续时拒绝提交阶段性更改,例如失败的“exec”,这依赖于检查run_git_commit()中是否缺少作者脚本。
这将防止提交暂存的更改,但打印

error: could not open '.git/rebase-merge/author-script' for
reading

在你说我不能承诺之前
这会让用户感到困惑,因此检查消息文件反而会改善用户体验。
更新了现有的exec失败后拒绝提交的测试,以检查我们是否不再打印关于缺少作者脚本的错误消息。

相关问题