28

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

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

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

How can I clone this repo?

CharlesB
  • 86,532
  • 28
  • 194
  • 218
a_mark
  • 351
  • 1
  • 3
  • 5

18 Answers18

46

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.

That should take care of it.

Michael Scheper
  • 6,514
  • 7
  • 63
  • 76
Daniel Lee
  • 2,030
  • 1
  • 23
  • 29
  • 4
    No luck doing this. Or with the suggestion to run it at the console. Any ideas? – kburns Apr 25 '12 at 00:02
  • If you're not being able to clone from the console, the problem is independent of EGit. Could you send some more information on server configuration, command, etc.? – Daniel Lee Apr 25 '12 at 09:13
19

Adding .git to the repository url worked for me.

Memet Olsen
  • 4,578
  • 5
  • 40
  • 50
5

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.

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".

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\.ssh directory. Providing Passphrase is optional here.

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

Anuruddha
  • 1,367
  • 6
  • 19
  • 38
3

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. If the URI starts with git://, try changing it to http:// or https://.

Michael Scheper
  • 6,514
  • 7
  • 63
  • 76
3

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://git@bitbucket.com/user/repository.git

It worked (branches listed) with this URL:
git@bitbucket.org:user/repository.git

Roberto
  • 500
  • 5
  • 9
2

I also found that the default SSH2 directory assigned in

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

Home was C:\Users\username\ssh instead of the default C:\Users\username\.ssh (with a leading dot for "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.

Thiem Nguyen
  • 6,345
  • 7
  • 30
  • 50
  • Also if you're not using `id_rsa` as file name for your private key, you also have to add the proper file name using "Add Private Key..." in the dialog described above. – Anticom Jan 29 '16 at 14:46
2

In my case it was a two step solution on 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.

Hope that helps.

Kurt
  • 123
  • 5
  • I followed this and it worked for me... I am using AWS Toolkit in STS bundled with Eclipse. In following this my path had a .ssh BUT I clicked browse and "re-selected" the correct folder. And it started working. – Koffeeaddict4eva Jul 09 '20 at 20:43
1

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.

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.

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.

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.

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 120 I have more time to drink my tea and when I return there are all the branches ready to clone :)

CharlesB
  • 86,532
  • 28
  • 194
  • 218
nuala
  • 2,681
  • 4
  • 30
  • 50
1

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

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.

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

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

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

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

1

If your using Debian based operating system you can try ssh service for cloning the Git repository.

It working fine to me.

Thanks, Sengottuvel

1

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

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

0

Restarting Eclipse resolved this problem for me.

Matt Sgarlata
  • 1,761
  • 1
  • 16
  • 13
0

I accidently found out simply changing protocol to git can fix it with egit 1.2.

user1458290
  • 279
  • 2
  • 7
  • 18
0

I had the same problem, when I just generated my new SSH2 key in eclipse, BUT not set into the private keys field... (Window --> Preferences --> General --> Network Connection --> SSH2 --> (General tab) --> Add private key...)

akasha
  • 494
  • 6
  • 4
0

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. I pointed the correct .ssh path in Windows >> Preferences ... >> Network ..>> SSH2.

  • Go to github web interface
  • Click on the repository
  • Click on ssh hyperlink just below the 'Copy Clone URL'
  • Click on the copy icon; it shows git@git.mycompany.com
  • Open the eclipse(STS,GGTS etc) it is having the git plugin
  • Open Git perspective and then just right click on Git Repositories pane which showed an option to 'Paste the repository path or URI'
  • This cloned the repo successfully.
Shamseer
  • 682
  • 1
  • 11
  • 24
0

I resolved this issue changing Active Provider to Direct in Network Connections.

AAA
  • 1
0

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

when it should have only been https://github.com/user-name/repo-name.git

Chris Gong
  • 8,031
  • 4
  • 30
  • 51
0

This is how I setup the fields in the ssh configuration of a repository under "ssh://user@192.168.xxx.yyy"

on this remote machine the target folder structure looks like this

~/Repository/target/.git

The trick in my case was adding the "~/" at the beginning of Repository path, I was writing either "Repository/target" or "/Repository/target" and was getting mad at it.

example of EGit configuration