Windows git remote 按字面意思处理 git 客户端在远程路径中插入的引号:如何禁用它们?

Windows git remote 按字面意思处理 git 客户端在远程路径中插入的引号:如何禁用它们?

我正在尝试将 Windows 10 PC 上装有 git 2.23.0 的远程版本添加到运行 Windows Server 2012 和 git 2.34.1 的远程计算机上的 git 存储库中。

我使用以下方式在远程设置 OpenSSHWin32的OpenSSH,因此 SSH 登录到 Powershell。但是 Powershell 不像 *nix shell 那样处理用单引号括起来的路径,而是按字面意思处理路径中的单引号。这很重要,因为远程命令git pull/fetch/ls-remote会将发送到远程的路径括在单引号中,如尝试执行以下操作所证明的那样ls-remote

$ GIT_TRACE=1 git ls-remote user@addr:path_to/repo
17:22:31.451511 exec-cmd.c:237          trace: resolved executable dir: C:/Users/me/Git/mingw64/bin
17:22:31.457170 git.c:440               trace: built-in: git ls-remote user@addr:/path_to/repo/
17:22:31.457170 run-command.c:663       trace: run_command: unset GIT_PREFIX; ssh user@addr 'git-upload-pack '\''/path_to/repo/'\'''
fatal: ''/path_to/repo/'' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists. 

请注意,第一个致命症状如下''/path/to/repo''

  • 外面的引号来自错误消息。
  • 由于第三条跟踪中的命令,内部引号是真正的引号:git-upload-pack '\''/path_to/repo/'\''

我确信情况是这样的,因为如果我创建一个名为的目录,并在其中创建'path_to一个 repo 目录,它就可以工作。repo'

是否有任何 git 客户端选项可以禁用这些单引号包装,或者 Powershell 选项可以读取用单引号包装的路径,或者甚至更高版本的git-upload-pack选项可以删除这些引号?

相关内容