git space 漂亮格式占位符之间

git space between pretty format placeholders

出于某种原因 (this reason),我可能不得不 运行 一个 git 命令,如下所示:

git log --pretty=format:{\"author\":\"%aE <%aD>\"}

但是它不起作用,我得到这个错误信息:

fatal: ambiguous argument '<%aD>"}': unknown revision or path not in the working tree.

但是没有 space 的相同命令效果很好:

git log --pretty=format:{\"author\":\"%aE<%aD>\"}

您知道如何解决这个问题或如何插入 space "programmatically" 和另一个占位符吗? 谢谢!

由于您没有引用 --pretty 的参数,因此您必须转义 space,例如:

git log --pretty=format:{\"author\":\"%aE\ <%aD>\"}

否则<%aD>\"}将被解释为下一个参数。

编辑:或者尝试引用整个论点,例如

git log --pretty="format:{\"author\":\"%aE <%aD>\"}"

Edit2:cmd 的转义字符似乎是 ^,所以尝试:

git log --pretty=format:{\"author\":\"%aE^ <%aD>\"}