简体   繁体   English

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

[英]Can't clone remote git repository with EGit

I am trying to clone remote git repository with Egit, via https protocol.我正在尝试通过 https 协议用 Egit 克隆远程 git 存储库。 I followed this online tutorial .我跟着这个在线教程

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?

It sounds like Egit is looking for an ssl certificate and refusing to function without it. 听起来Egit正在寻找ssl证书,并拒绝没有它的功能。 A good fix to make the problem go away and stay away: Window→Preferences→Team→Git→Configuration→New Entry→ http.sslverify = false . 一个使问题消失并远离的好方法:窗口→首选项→团队→Git→配置→新条目→ http.sslverify = false

That should take care of it. 那应该照顾它。

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

This worked for me. 这对我有用。

1) In Eclipse, Window -> Preferences -> General -> Network Connections -> SSH2 (Or else just type SSH2 on search filter). 1)在Eclipse中, Window -> Preferences -> General -> Network Connections -> SSH2 (或者在搜索过滤器上键入SSH2)。 Go to "Key Management" tab. 转到"Key Management"选项卡。 Click on "Generate RSA Key" . 单击"Generate RSA Key" You can now see the generated key information. 现在,您可以看到生成的密钥信息。 Copy this generated key. 复制此生成的密钥。 Keep this window open and do step 2. 保持此窗口打开并执行步骤2。

2) Go to GitHub account.Click on your profile -> Manage Account -> SSH keys -> Add key . 2)转到GitHub帐户。 profile -> Manage Account -> SSH keys -> Add key您的profile -> Manage Account -> SSH keys -> Add key Now Paste the previously copied key and then "Add key" . 现在粘贴先前复制的密钥,然后粘贴"Add key"

3) Now go back to eclipse Preferences window. 3)现在返回eclipse Preferences窗口。 Click "Save Private Key" to save RSA key to a file. 单击"Save Private Key"将RSA密钥保存到文件。 By defaults this will be saved to Users\\user_name\\.ssh directory. 默认情况下,它将保存到Users\\user_name\\.ssh目录。 Providing Passphrase is optional here. 此处提供密码是可选的。

That's all, Now restart Eclipse and clone the repository. 就这样,现在重新启动Eclipse并克隆存储库。

Not helpful in your case, but maybe helpful for others: I've seen this error come up when copying URIs with scheme name git instead of something more common. 对您的情况没有帮助,但可能对其他人有所帮助:复制方案名称为git而不是更常见的名称的URI时,我已经看到此错误。 If the URI starts with git:// , try changing it to http:// or https:// . 如果URI以git://开头,请尝试将其更改为http://https://

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: 尝试使用SSH密钥以及bitbucket的错误URL时:
wrong? 错误? ssh://git@bitbucket.com/ user/repository .git ssh://git@bitbucket.com/ 用户/存储库 .git

It worked (branches listed) with this URL: 它使用以下URL起作用(列出了分支):
git@bitbucket.org: user/repository .git git@bitbucket.org: 用户/存储库 .git

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\\ssh instead of the default C:\\Users\\username\\.ssh (with a leading dot for "ssh") 主目录为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. 如果这与您相关,那么只需消除指定的目录即可消除错误消息。

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"). 我的猜测是,该插件仅捕获基础命令的异常(可能是ssh,因为在ls上执行失败,这很可能是成功连接后的第一个命令),并显示它自己的消息(“ ls命令的执行”) 。 Therefore it is hard to give a working answer. 因此,很难给出有效的答案。 I tried Daniel's answer it it didn't worked for me. 我尝试了丹尼尔的答案,但这对我没有用。

So I dug deeper and tried to manually clone the repository via 所以我更深入地挖掘并尝试通过以下方式手动克隆存储库

git clone username@host.path_to_repo

and it worked charming. 而且效果很好。

By doing so you test if your authentication method is what you expect and your .ssh/config is pretty as well. 这样,您可以测试您的身份验证方法是否符合您的期望,并且.ssh/config也是如此。

Knowing I could connect I assumed the error must be somewhere in Eclipse/EGit. 知道可以连接后,我认为错误一定是在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.) (将ssh://放在路径的前面,可能会干扰.ssh/config config-无论如何:不。)
Or maybe the SSH settings for Eclipse were wrong: Window --> Preferences --> General --> Network Connection --> SSH . 也许Eclipse的SSH设置错误: 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. 我找不到任何好的理由。

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! 拼命地我重新检查了Window- Window --> Preferences --> Team --> Git --> Team- Window --> Preferences --> Team --> Git --> Git- Window --> Preferences --> Team --> Git --> and KABAMM! I found the settings I actually was initially thinking it could be the troublemaker. 我发现最初实际上以为是麻烦制造者的设置。

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. 正如我所说的那样,我感觉就像蜗牛和git-plugin在服务器响应甚至未到达之前就放弃了,而不是快如闪电。 At least that's my assumption 'cause since I've set the value to 120 I have more time to drink my tea and when I return there are all the branches ready to clone :) 至少这是我的假设,因为自从我将值设置为120以来,我有更多时间喝茶,当我返回时,所有分支都可以克隆了:)

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的路径正确。

If your using Debian based operating system you can try ssh service for cloning the Git repository. 如果您使用的是基于Debian的操作系统,则可以尝试使用ssh服务来克隆Git存储库。

It working fine to me. 对我来说很好。

Thanks, Sengottuvel 谢谢,Sengottuvel

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. 我使用的是id_rsa证书,因此需要更改“首选项”>“常规”>“网络连接”>“ SSH2”>“常规”>“ SSH2”中的位置,以指向.ssh而不是早期解决方案中指出的ssh。 In addition to that, I had to give read access back to Everybody (right click the file in Windows Explorer). 除此之外,我还必须授予所有人的读取访问权限(在Windows资源管理器中右键单击该文件)。 I had previously denied access to Everybody because my command line ssh client refused to work without doing so. 我以前曾拒绝访问所有人,因为我的命令行ssh客户端拒绝了不这样做的工作。

Hope that helps. 希望能有所帮助。

when you generate the RSA ssh key in eclipse in : Windows > Preferences > General> Network.. > SSH2 > key Managment tab.. 当您在Eclipse中的Eclipse中生成RSA ssh密钥时:Windows>首选项>常规>网络..> SSH2>密钥管理选项卡。

YOU SHOULD save as the private key and then continue. 您应该另存为私钥,然后继续。 That solved my problem. 那解决了我的问题。

重新启动Eclipse为我解决了这个问题。

我无意中发现,只需将协议更改为git即可使用egit 1.2对其进行修复。

我有同样的问题,当我刚刚产生了日食我的新SSH2关键, 不能设置为私有密钥场...( Window --> Preferences --> General --> Network Connection --> SSH2 --> (General tab) --> Add private key...

I did the following steps in my Eclipse when I had issue with Auth Fail and unexpected exception even after setting the ssh key with Github from mylaptop. 即使在使用mylaptop的Github设置ssh密钥后,当Auth Fail和意外异常出现问题时,我仍在Eclipse中执行了以下步骤。 I pointed the correct .ssh path in Windows >> Preferences ... >> Network ..>> SSH2. 我在Windows >>偏好设置>> >>网络.. >> SSH2中指出了正确的.ssh路径。

  • Go to github web interface 转到github Web界面
  • Click on the repository 单击存储库
  • Click on ssh hyperlink just below the 'Copy Clone URL' 单击“复制克隆URL”下方的ssh超链接
  • Click on the copy icon; 单击复制图标; it shows git@git.mycompany.com 它显示git@git.mycompany.com
  • Open the eclipse(STS,GGTS etc) it is having the git plugin 打开有git插件的eclipse(STS,GGTS等)
  • Open Git perspective and then just right click on Git Repositories pane which showed an option to 'Paste the repository path or URI' 打开Git透视图,然后右键单击Git Repositories窗格,其中显示了“粘贴存储库路径或URI”的选项
  • This cloned the repo successfully. 这样成功克隆了仓库。

我解决了将Active Provider更改为Direct in Network Connections的问题。

This was a stupid mistake on my part that I hope no one else has to encounter. 就我而言,这是一个愚蠢的错误,我希望没有其他人会遇到。

In the Host field, I included www at the very beginning, so the complete URI looked something like, https://www.github.com/user-name/repo-name.git 在“ 主机”字段中,我一开始就包含了www ,因此完整的URI看起来像https://www.github.com/user-name/repo-name.git

when it should have only been https://github.com/user-name/repo-name.git 当它应该只是https://github.com/user-name/repo-name.git

Git accepting login using only App access key PFB link to get access key https://bitbucket.org/account/settings/app-passwords/new Git 接受仅使用 App 访问密钥 PFB 链接登录以获取访问密钥https://bitbucket.org/account/settings/app-passwords/new

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

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