我试图切换我的分支,但是由于我正在重新定基,所以无法切换:
fatal: cannot switch branch while rebasing
Consider "git rebase --quit" or "git worktree add".
结果显示:
Next commands to do (2 remaining commands):
pick d51f32027a0 Correct last code block not annotated
pick 7380fa4a8e7 changed all @doc issues
(use "git rebase --edit-todo" to view and edit)
所以我这么做了
git rebase --edit-todo
它在 Vim 中打开了一个文件,我对其进行了如下编辑:
pick d51f32027a0 Correct last code block not annotated
pick 7380fa4a8e7 changed all @doc issues
git rebase --continue
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
# commit's log message, unless -C is used, in which case
# keep only this commit's message; -c is same as -C but
# opens the editor
关闭它之后,我以为它会继续进行变基。但现在有这样的输出:
git rebase --continue
error: invalid command 'git'
error: invalid line 3: git rebase --continue
error: please fix this using 'git rebase --edit-todo'.
我应该怎么办?
除了删除 rebase 文件中的无效行
todo
并解决冲突之外,还请注意:解决重新定基意味着(一旦合并冲突标记被删除):
可以立即中止
git rebase --abort
,或者git rebase --quit
如果您忘记中止变基,可以稍后再中止(这可能是您的情况,当您尝试切换分支时,您意识到变基正在进行中)。通过添加工作树
main
始终可以进行访问:这样,您就拥有一个单独的文件夹
main
,可以让您在原始目录中继续进行变基操作。您已将文本插入
git rebase --continue
到 rebase todo 文件中。再次运行
git rebase --edit-todo
,删除文本,只保留pick
行,保存,退出并git rebase --continue
在命令行中运行。根据phd的评论。