我可以在Linux上执行ssh windowsmachine
来访问Windows机器,然后从那里可以git init --bare foo.git
告诉我Initialized empty Git repository in C:/Users/unhammer/foo.git/
但是如何从Unix方面克隆呢?
$ git clone ssh://windowsmachine:foo.git
Cloning into 'foo'...
fatal: No path specified. See 'man git-pull' for valid url syntax
$ git clone ssh://windowsmachine:C:\\Users\\unhammer\\foo.git
Cloning into '\Users\unhammer\foo'...
fatal: No path specified. See 'man git-pull' for valid url syntax
$ git clone ssh://windowsmachine:/foo.git
Cloning into 'foo'...
fatal: ''/foo.git'' 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.
以及
/C:/Users/unhammer/foo.git
和类似消息/C/Users/unhammer/foo.git
和/Users/unhammer/foo.git
。请注意双单引号:
fatal: ''/Users/unhammer/foo.git'' does not appear to be a git repository
当我尝试
git clone linuxmachine:/some/path/that/does/not/exist.git
时,这不会发生,然后git使用单引号引起来。 (也许就是这个问题,是git-for-windows还是使用了额外引号的东西?) 最佳答案
最简单的解决方案是change the default Windows OpenSSH shell to bash。您可以从Windows机器上的powershell轻松完成此操作:
powershell
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Program Files\Git\bin\bash.exe" -PropertyType String -Force
在生效之前,您可能必须在Windows计算机上重新启动OpenSSH和/或从客户端终止现有的ssh连接。现在,您可以克隆而无需任何额外的-u选项:
git clone ssh://windowsmachine/c/Users/unhammer/foo.git
(如果您之前指定了uploadpack/receivepack,请从.git/config中删除它们)