简体   繁体   English

TortoiseGit:无法使用SSH在VPS上使用Git克隆私有存储库

[英]TortoiseGit: Unable to Git clone private repository on VPS using SSH

I am trying to git clone a repository using TortoiseGit. 我正在尝试使用TortoiseGit git克隆存储库。 I only have access of SSH to my git repository on VPS. 我只能在VPS上访问我的git存储库的SSH。 I am getting the following error: 我收到以下错误:

git.exe clone --progress -v "ssh://git@xx.xx.xx.xx/home/git/git-repo/myproject.git" "C:\xampp\htdocs\myproject"

Cloning into 'C:\xampp\htdocs\myproject'...
/usr/bin/bash: git@xx.xx.xx.xx: No such file or directory
fatal: Could not read from remote repository.

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

However, I am able to git clone my private repository using Git Bash on windows. 但是,我能够在Windows上使用Git Bash克隆我的私有存储库。 That is strange. 这很奇怪。 Am I doing correct while using TortoiseGit for SSH? 我在使用TortoiseGit进行SSH时是否正确?

Although I'm not familiar with TortoiseGit, it looks like you should be using a syntax which is common amongst many application where copying is done over SSH. 虽然我不熟悉TortoiseGit,但看起来你应该使用的语法在许多通过SSH完成复制的应用程序中很常见。 That is: <username>@<server>:/path/to/thing/that/needs/copying . 即: <username>@<server>:/path/to/thing/that/needs/copying (Note the colon near the middle.) (注意中间附近的冒号。)

I propose change the command you are running to put a colon just before /home : 我建议改变你正在运行的命令,在/home之前放一个冒号:

git.exe clone --progress -v "ssh://git@xx.xx.xx.xx:/home/git/git-repo/myproject.git" "C:\xampp\htdocs\myproject"

However, I am able to git clone my private repository using Git Bash on windows 但是,我能够在Windows上使用Git Bash克隆我的私有存储库

Since you are on Windows, try for testing to use and uncompress the latest Git for Windows portable archive PortableGit-2.19.0-64-bit.7z.exe anywhere you want. 由于您使用的是Windows,请尝试进行测试, PortableGit-2.19.0-64-bit.7z.exe在任何地方使用PortableGit-2.19.0-64-bit.7z.exe压缩最新的Git for Windows便携式存档PortableGit-2.19.0-64-bit.7z.exe

Then setup a simplified path in a CMD session. 然后在CMD会话中设置简化路径。

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
set GIT_HOME=C:\Path\to\Git
set PATH=%GIT_HOME%;%GIT_HOME%\bin;%GIT_HOME%\usr\bin;%GIT_HOME%\mingw64\bin;%PATH%

Check that the exact same command than the one used by TortoiseGit is still working: 检查与TortoiseGit使用的命令完全相同的命令是否仍然有效:

git.exe clone --progress -v "ssh://git@xx.xx.xx.xx/home/git/git-repo/myproject.git" "C:\xampp\htdocs\myproject"

Finally, still from that CMD, launch the Tortoisegitproc.exe GUI executable, and see if the clone can proceed from this session. 最后,仍然从该CMD启动Tortoisegitproc.exe GUI可执行文件,并查看克隆是否可以从此会话继续。

If you prefer to clone using ssh key, you need to create and add ssh key to git repositories ssh public keys. 如果您更喜欢使用ssh密钥进行克隆,则需要创建ssh密钥并将其添加到git存储库ssh公钥。 Use ssh-keygen to generate your ssh key 使用ssh-keygen生成ssh密钥

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM