我正在尝试将 git 存储库从我的桌面克隆到我的笔记本电脑。
台式机设置为 ssh 服务器并可从笔记本电脑访问。
我尝试了多个具有不同 url 格式的命令,
git clone desktop:workspace/project
git clone desktop:/C:/Users/nkgcp/workspace/project
git clone desktop:~workspace/project
git clone ssh://desktop/workspace/project
git clone ssh://desktop/C:/Users/nkgcp/workspace/project
git clone ssh://desktop/c/Users/nkgcp/workspace/project
但是这些都返回了相同的错误。
Cloning into 'project'...
fatal: ''workspace/project'' 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.
请注意,第二行的路径用两个单引号引起来。
project
存在于 workspace
文件夹中,并且它肯定是用 git 初始化的。
workspace
文件夹位于我桌面的主目录中。
台式机和笔记本电脑都是Windows 10,台式机使用内置的OpenSSH Server。
这是我桌面的 sshd_config
,
PubkeyAuthentication yes
PasswordAuthentication no
AllowAgentForwarding no
AllowTcpForwarding no
ChrootDirectory c:/Users/nkgcp
Subsystem sftp sftp-server.exe
这是我笔记本电脑的.ssh/config
。
Host desktop
HostName [desktop ip]
User nkgcp
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_ed25519
我该如何解决这个问题?
提前致谢。
编辑
我检查了 git ssh 的调试日志。
Cloning into 'project'...
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Reading configuration data C:\\Users\\nkgcp/.ssh/config
debug1: Connecting to desktop [192.168.25.2] port 22.
debug1: Connection established.
...
debug1: Authentication succeeded (publickey).
Authenticated to desktop ([192.168.25.2]:22).
...
debug1: Sending command: git-upload-pack 'workspace/project'
...
debug1: Exit status 128
可以看到只执行了git-upload-pack
,所以错误可能就是由此而来。
最佳答案
首先,检查ssh desktop
工作并打开一个交互式 session 。
然后,检查 ssh desktop ls /c/Users/nkgcp/workspace/project
确实列出了远程存储库的内容。
为了测试,我还会删除 ChrootDirectory
指令,只是为了检查它是否有限制性副作用。
最后,尝试使用克隆命令:
git clone ssh://desktop/c/Users/nkgcp/workspace/project
看看你有没有 GIT_SSH
environment variable ,如果没有,看看是否将其设置为 C:\Program Files\Git\usr\bin\ssh.exe
或C:\Windows\Sysnative\OpenSSH\ssh.exe
没有任何区别。
关于git - '' 路径'' 似乎不是 git 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71828761/