无法使用 EGit 克隆远程 git 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9481818/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:03:48  来源:igfitidea点击:

Can't clone remote git repository with EGit

eclipsegitegit

提问by a_mark

I am trying to clone remote git repository with Egit, via https protocol. I followed this online tutorial.

我正在尝试通过 https 协议使用 Egit 克隆远程 git 存储库。我跟着这个在线教程

When I insert URI: https://username@host:port/repositorypath, password and click NEXT, I am getting this error message:

当我插入 URI:https://username@host:port/repositorypath,密码并单击 NEXT 时,我收到此错误消息:

Cannot list the available branches.
Reason:
Exception caught during execution of ls-remote command.

How can I clone this repo?

我怎样才能克隆这个 repo?

回答by Daniel Lee

It sounds like Egit is looking for an ssl certificate and refusing to function without it. A good fix to make the problem go away and stay away: Window→Preferences→Team→Git→Configuration→New Entry→http.sslverify=false.

听起来 Egit 正在寻找 ssl 证书并拒绝在没有它的情况下运行。使问题消失并远离的好方法: Window→Preferences→Team→Git→Configuration→New Entry→ http.sslverify= false

That should take care of it.

那应该照顾它。

回答by Memet Olsen

Adding .git to the repository url worked for me.

将 .git 添加到存储库 url 对我有用。

回答by Anuruddha

This worked for me.

这对我有用。

1) In Eclipse, Window -> Preferences -> General -> Network Connections -> SSH2(Or else just type SSH2 on search filter). Go to "Key Management"tab. Click on "Generate RSA Key". You can now see the generated key information. Copy this generated key. Keep this window open and do step 2.

1) 在 Eclipse 中,Window -> Preferences -> General -> Network Connections -> SSH2(或者只是在搜索过滤器上输入 SSH2)。转到"Key Management"选项卡。单击"Generate RSA Key"。您现在可以看到生成的密钥信息。复制此生成的密钥。保持此窗口打开并执行步骤 2。

2) Go to GitHub account.Click on your profile -> Manage Account -> SSH keys -> Add key. Now Paste the previously copied key and then "Add key".

2) 转到 GitHub 帐户profile -> Manage Account -> SSH keys -> Add key。单击您的. 现在粘贴之前复制的密钥,然后粘贴"Add key"

3) Now go back to eclipse Preferences window. Click "Save Private Key"to save RSA key to a file. By defaults this will be saved to Users\user_name\.sshdirectory. Providing Passphrase is optional here.

3) 现在回到 eclipse Preferences 窗口。单击"Save Private Key"以将 RSA 密钥保存到文件。默认情况下,这将保存到Users\user_name\.ssh目录。此处提供密码是可选的。

That's all, Now restart Eclipse and clone the repository.

就是这样,现在重新启动 Eclipse 并克隆存储库。

回答by Rock

I was getting this error

我收到此错误

Cannot list the available branches. 
Reason: 
Exception caught during execution of ls-remote command.

when trying with SSH Key and maybe wrong URL for bitbucket:
wrong? ssh://[email protected]/user/repository.git

尝试使用 SSH 密钥时,可能是 bitbucket 的 URL错误
错误?SSH://[email protected]/用户/库的.git

It worked (branches listed) with this URL:
[email protected]:user/repository.git

它与此 URL 一起工作(列出了分支):
[email protected]: user/repository.git

回答by Michael Scheper

Not helpful in your case, but maybe helpful for others: I've seen this error come up when copying URIs with scheme name gitinstead of something more common. If the URI starts with git://, try changing it to http://or https://.

对您的情况没有帮助,但可能对其他人有帮助:我已经看到在复制具有方案名称git而不是更常见的URI 时出现此错误。如果 URI 以 开头git://,请尝试将其更改为http://https://

回答by Bevan Thistlethwaite

I also found that the default SSH2 directory assigned in

我还发现分配的默认SSH2目录

Preferences > General > Network Connections > SSH2 > General > SSH2

首选项 > 常规 > 网络连接 > SSH2 > 常规 > SSH2

Home was C:\Users\username\sshinstead of the default C:\Users\username\.ssh(with a leading dot for "ssh")

Home 是C:\Users\username\ssh而不是默认的C:\Users\username\.ssh(带有“ssh”的前导点)

Using the Browse button should help you to ensure that the proper directory is selected.

使用浏览按钮应该可以帮助您确保选择了正确的目录。

If this is relevant to you then changing the specified directory is all you need to eliminate the error messages.

如果这与您相关,那么您只需更改指定的目录即可消除错误消息。

回答by Andrey Svirsky

My answer is for the same exception, but for cloning using SSH protocol.

我的答案是针对相同的例外,但针对使用 SSH 协议进行克隆。

I had it working in one workspace, but not the other one. I could also clone repository from command line so it was clear Eclipse configuration issue.

我让它在一个工作区工作,但不是另一个工作区。我还可以从命令行克隆存储库,因此很明显 Eclipse 配置问题。

I did compare config files in two workspaces. The thing that fixed it was in .metadata.plugins\org.eclipse.core.runtime.settings\org.eclipse.jsch.core.prefs

我确实比较了两个工作区中的配置文件。修复它的东西在 .metadata.plugins\org.eclipse.core.runtime.settings\org.eclipse.jsch.core.prefs

There was a path to SSH directory: SSH2HOME=C\:\Users\username\ssh

SSH 目录有一个路径:SSH2HOME=C\:\Users\username\ssh

The correct path should have had a dot in front of ssh: SSH2HOME=C\:\Users\username\.ssh

正确的路径应该在 ssh 前面有一个点:SSH2HOME=C\:\Users\username\.ssh

No idea how that got messed up, but make sure the path to ssh home is correct.

不知道这是怎么搞砸的,但要确保 ssh home 的路径是正确的。

回答by nuala

I think this error message is in some kind generic. My guess is the plug-in just catches an exception by the underlying commands (probably ssh, since execution fails on ls, which is likely the first command after a successful connection) and show it's own message ("execution of the ls command"). Therefore it is hard to give a working answer. I tried Daniel's answer it it didn't worked for me.

我认为此错误消息是某种通用的。我的猜测是插件只是通过底层命令捕获异常(可能是 ssh,因为在 ls 上执行失败,这可能是成功连接后的第一个命令)并显示它自己的消息(“执行 ls 命令”) . 因此,很难给出有效的答案。我试过丹尼尔的回答,它对我不起作用。

So I dug deeper and tried to manually clone the repository via

所以我深入挖掘并尝试通过手动克隆存储库

git clone [email protected]_to_repo

and it worked charming.

它很有魅力。

By doing so you test if your authentication method is what you expect and your .ssh/configis pretty as well.

通过这样做,您可以测试您的身份验证方法是否符合您的预期,并且您的身份验证方法是否.ssh/config也很漂亮。

Knowing I could connect I assumed the error must be somewhere in Eclipse/EGit. For example I thought maybe the authentication method in the project import wizard was disturbing. (Putting an ssh:// in front of the path, might interfering with .ssh/config- anyway: nope.)
Or maybe the SSH settings for Eclipse were wrong: Window --> Preferences --> General --> Network Connection --> SSH. OH, some of my keys were not listed. Adding and restarting: same error -> frustration. All other settings looked fine. I couldn't find any good reason.

知道我可以连接我假设错误一定在 Eclipse/EGit 中的某个地方。例如,我认为项目导入向导中的身份验证方法可能令人不安。(将 ssh:// 放在路径前面,可能会干扰.ssh/config- 无论如何:不。)
或者 Eclipse 的 SSH 设置可能是错误的:Window --> Preferences --> General --> Network Connection --> SSH. 哦,我的一些钥匙没有列出。添加和重新启动:相同的错误 -> 挫折。所有其他设置看起来都很好。我找不到任何好的理由。

Also my connection is not the best so every connection try takes a lot of time. Desperately I re-checked Window --> Preferences --> Team --> Git -->and KABAMM! I found the settings I actually was initially thinking it could be the troublemaker.

另外我的连接不是最好的,所以每次连接尝试都需要很多时间。我拼命重新检查Window --> Preferences --> Team --> Git -->和KABAMM!我发现我最初认为它可能是麻烦制造者的设置。

Remote connection timeout (seconds): 30

As I said instead of lightning fast I feel more like a snail and git-plugin gave up before the server response even could reach me. At least that's my assumption 'cause since I've set the value to 120I have more time to drink my tea and when I return there are all the branches ready to clone :)

正如我所说的,而不是闪电般的快速,我感觉更像是蜗牛和 git-plugin 在服务器响应甚至可以到达我之前就放弃了。至少这是我的假设,因为我已经将值设置为120我有更多时间喝茶,当我回来时,所有分支都准备好克隆:)

回答by Kurt

In my case it was a two step solution on Windows Vista.

就我而言,它是 Windows Vista 上的两步解决方案。

I am using an id_rsa certificate, so I needed to change the location in Preferences > General > Network Connections > SSH2 > General > SSH2 to point to .ssh instead of ssh as was pointed out in an earlier solution. In addition to that, I had to give read access back to Everybody (right click the file in Windows Explorer). I had previously denied access to Everybody because my command line ssh client refused to work without doing so.

我正在使用 id_rsa 证书,因此我需要更改 Preferences > General > Network Connections > SSH2 > General > SSH2 中的位置以指向 .ssh 而不是 ssh ,正如之前的解决方案中指出的那样。除此之外,我还必须将读取权限授予每个人(在 Windows 资源管理器中右键单击该文件)。我之前拒绝访问每个人,因为我的命令行 ssh 客户端拒绝在不这样做的情况下工作。

Hope that helps.

希望有帮助。

回答by Farzaneh Tabataba

when you generate the RSA ssh key in eclipse in : Windows > Preferences > General> Network.. > SSH2 > key Managment tab..

当您在 Eclipse 中生成 RSA ssh 密钥时:Windows > Preferences > General> Network.. > SSH2 > key Managment tab..

YOU SHOULD save as the private key and then continue. That solved my problem.

您应该保存为私钥,然后继续。那解决了我的问题。