git cat-file -p master ^ {tree}在zsh中输出错误

Boo*_*oon 2 git zsh

gitscm.org文档中,在git objects章节下,它使用下面的命令,但是尝试它会给我"zsh:找不到匹配项:master ^ {tree}".知道什么是不正确的吗?

git cat-file -p master^{tree}
Run Code Online (Sandbox Code Playgroud)

Kla*_*urn 6

我发现在指定那些更棘手的git修订版参数时,我必须引用它们

git cat-file -p "master^{tree}"
Run Code Online (Sandbox Code Playgroud)

而遗漏"失败.

此行为及其原因因平台而异:

  • 在Windows上,在PowerShell和cmd.exe中,该^字符用于转义.所以,作为替代方案,你可以写git cat-file -p master^^{tree}
  • 在zsh中,该^字符用于globbing
  • 在bash中,命令不带引号

(感谢Wumpus Q. Wumbley和kostix的解释)