我可以在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还是使用了额外引号的东西?)
答案 0 :(得分:1)
最简单的解决方案是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中删除它们)
答案 1 :(得分:0)
在@phd到https://stackoverflow.com/a/8050564/7976758的链接之后,我找到了对https://stackoverflow.com/a/2323826/69663的引用,并提供了解决引号问题的方法。这是我所做的:
在Windows上,打开Git Bash,然后在我的主目录中:
echo 'git-receive-pack "$@"' >grp.sh
echo 'git-upload-pack "$@"' >gup.sh
在Linux上,克隆并指定上载包:
git clone -u '"C:/Program Files/Git/bin/bash.exe" gup.sh' ssh://windowsmachine/c/Users/unhammer/foo.git
cd foo
git config remote.origin.uploadpack '"C:\Program Files\Git\bin\bash.exe" gup.sh'
git config remote.origin.receivepack '"C:\Program Files\Git\bin\bash.exe" grp.sh'
因此回购路径就是Git Bash显示的路径(/c/Users/$username/$repo
),任何地方都没有冒号。
https://github.com/PowerShell/Win32-OpenSSH/issues/1082似乎相关。