编辑rebase todo文件后执行git rebase --continue报错“invalid command 'git'”如何解决?
解决Git Rebase中的无效命令错误
问题根源是你在rebase的todo文件中添加了不属于rebase命令集的git rebase --continue——该文件仅支持定义对提交的操作指令(如pick、reword等),不能直接写入Git命令。按以下步骤修复:
- 重新打开rebase todo文件:
git rebase --edit-todo - 在Vim编辑器中,删除第三行的
git rebase --continue内容,确保文件内容回到正确格式:pick d51f32027a0 Correct last code block not annotated pick 7380fa4a8e7 changed all @doc issues # # 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 - 保存并退出Vim(按
Esc,输入:wq回车) - 继续执行rebase流程:
git rebase --continue
等rebase完成后,即可正常执行git checkout <分支名>或git switch <分支名>切换分支。
内容的提问来源于stack exchange,提问作者Milenko Markovic
相关产品推荐
相关产品推荐

