问题
I did:
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
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'.
What? But pick
is a valid command!
Why did this happen, and how can I fix it?
Output of git --version
:
git version 2.8.1.windows.1
I'm running Windows 10.
回答1:
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.)
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
来源:https://stackoverflow.com/questions/39401434/why-does-git-give-unknown-command-pick-during-an-interactive-rebase