为什么Git会给出“未知命令:选择"?在进行互动式变基时? [英] Why does Git give "Unknown command: pick" during an interactive rebase?
问题描述
我做到了:
git rebase mybranch --interactive
然后我将待办事项文件编辑为如下内容:
And I edited my rebase-todo file to something like this:
pick aec2c2b Add foo method to bar
edit 8441f4b Do something slightly wrong
pick dabcc80 Do something else correctly
但是当我告诉Git实现它时,我得到了:
But when I told Git to make it happen, I got:
Unknown command: pick aec2c2b8f9c314f9dddc67a2c71f8be0a27c0fab Add foo method to bar
Please fix this using 'git rebase --edit-todo'.
什么?但是pick
是有效的命令!
What? But pick
is a valid command!
为什么会发生这种情况,我该如何解决?
Why did this happen, and how can I fix it?
git --version
的输出:
git version 2.8.1.windows.1
我正在运行Windows 10.
I'm running Windows 10.
推荐答案
由于我与使用Visual Studio的开发人员合作,因此我将编辑器配置为使用BOM将文件另存为UTF-8. Git不知道该如何处理BOM表,因此这就是我得到此错误的原因. (Git认为我尝试使用命令BOMpick
而不是pick
.您可以在我的问题中包含的错误消息中检测到BOM.)
Since I collaborate with developers who use Visual Studio, I have my editor configured to save files as UTF-8 with BOM. Git doesn't know what to do with BOMs, so that is why I got the error. (Git thinks I tried to use the command BOMpick
instead of pick
. You can detect the BOM in the error message I included in my question.)
删除BOM表可修复该错误.具体来说,我将此添加到了.editorconfig
:
Removing the BOM fixed the error. Specifically, I added this to my .editorconfig
:
[.git/**]
charset = utf-8
因为在文件顶部,它已经具有以下内容:
Because at the top of the file it already had this:
[*]
charset = utf-8-bom
这篇关于为什么Git会给出“未知命令:选择"?在进行互动式变基时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!