为什么 git commit 在 git Windows 上无法识别 --amend ?

Mic*_*eim 4 shell git command-line

我正在尝试遵循建议Can you GPG Sign old commits?

\n
\xce\xbb git rebase --exec \'git commit --amend --no-edit -n -S\' -i develop\n
Run Code Online (Sandbox Code Playgroud)\n

但得到

\n
error: unknown option `amend\'\n
Run Code Online (Sandbox Code Playgroud)\n

我正在运行 git 版本2.23.0.windows.1

\n

phu*_*clv 6

通过在提示字符串中使用 ,\xce\xbb我猜您正在使用 cmder 作为终端,并使用 cmd 作为 shell。在 cmd 中,单引号不是引用符号,因此 exec 字符串不会作为单个参数传递。您需要更改为双引号:

\n
git rebase --exec "git commit --amend --no-edit -n -S" -i develop\n
Run Code Online (Sandbox Code Playgroud)\n

或者更好地更改为 powershell 或其他 shell(如果你在 Windows 上安装 git,你应该已经有 bash)。它们被识别\'为引号字符,因此您无需更改任何内容,并且可以获得更多功能

\n