13

In Eclipse when I try to import a project from a repository (File > Import > Maven > Check out Maven Projects from SCM) I select 'git' (eGit installed), fill in the ssh://... address (all the keys and access permissions are set), finally type in the password for rsa and...

Invalid remote: origin: Invalid remote: origin

According to this: http://youtrack.jetbrains.com/issue/IDEA-77239 writing .git at the end of address should solve the problem but actually it does not.

I have totally no idea how to resolve it further. Any ideas?

Edit: And I use Windows. It seems like an important piece of information to add.

4
  • Try installing msysgit and see whether you can access the repository using the Git Bash that comes with it. That should give you a better idea of any issues rather than using an Eclipse plug-in.
    – codemonkey
    Jul 17, 2012 at 16:21
  • @codemonkey when I try to clone the project in msysgit I get R access for tracker-android DENIED to [username] (Or there may be no repository at the given path. Did you spell it correctly?) fatal: The remote end hung up unexpectedly. It looks like I'm doing some common mistake. But still, don't know what it is.
    – alex
    Jul 18, 2012 at 7:13
  • The error message is quite clear about the two possible issues. What is the URL you are using with msysgit? It needs to be of the form [email protected]:gitrepo. If the path is correct and the repository does exist then, as the error message tells you - you don't have permissions. So check your SSH keys.
    – codemonkey
    Jul 18, 2012 at 8:14
  • @codemonkey so here it is. just like you said and just like I thought - as simple as permissions. I wasn't granted all necessary rights on the server. Thanks for a tip!
    – alex
    Jul 18, 2012 at 9:05

5 Answers 5

12

This error can occur when there is an underlying SSH authentication issue, like having the wrong public key on the git remote server or if the git remote server changed its SSH host key.

Eclipse will use the .ssh directory you specify in Preferences -> General -> Network Connections -> SSH2 for its ssh configuration. Set it "{your default user directory}.ssh\" .

To fix things, first you need to determine which ssh client you are using for Git. This is stored in the GIT_SSH environmental variable. Right-click on "Computer" (Windows 7), then choose Properties -> Advanced System Settings -> Environment Variables.

If GIT_SSH contains a path to plink.exe, you are using the PuTTY stack.

  • To get your public key, open PuTTYgen.exe and then load your private key file (*.ppk). The listed public key should match the public key on the git remote server.
  • To get the new host key, open a new PuTTY.exe session, and then connect to git@{git repo host}.
  • Click OK and say yes to store the new key.
  • Once you get a login prompt, you can close the PuTTY window. The new key has been stored.
  • Restart Eclipse.

If GIT_SSH contains a path to "ssh.exe" in your "Git for Windows" tree, you are using Git for Windows's OpenSSH.

  • Set %HOME% to your default user directory (as listed in Eclipse; see above).
  • Set %HOMEDRIVE% to the drive letter of your default user directory.
  • Set %HOMEPATH% to the path to your default user directory on %HOMEDRIVE%
  • To get your public key, open the file %HOMEDRIVE%%HOMEPATH%/.ssh/id_rsa.pub (or id_dsa.pub) in a text editor. The listed public key should match the public key on the git remote server.
  • To get the new host key, run: cmd.exe
  • Run Git Bash
  • Ctrl-C
  • At the bash prompt, run /c/path/to/git/for/windows/bin/ssh.exe git@{git remote host}.
  • Type yes to accept the new key.
  • Once you have a login prompt, type: ctrl-c
  • Close the cmd.exe window
  • Restart Eclipse.

Finally, if you are still having trouble with your external ssh client, delete the GIT_SSH environmental variable and set the HOME environmental variable to your default user directory on Windows. Without the GIT_SSH variable, EGit will use its internal ssh client (java). It will use the .ssh directory you specified above as its SSH configuration directory.

Note: If you have Git for Windows, you can use its tools to create a SSH key pair your .ssh directory:

  • Set %HOME% to your default user directory (as listed in Eclipse).
  • Set %HOMEDRIVE% to the drive letter of your default user directory.
  • Set %HOMEPATH% to the path to your default user directory on %HOMEDRIVE%
  • Run Git Bash
  • Ctrl -C
  • Run: ssh-keygen.exe -t rsa -b 2048
  • Save to the default filenames
  • Choose a passphrase or save without one. If you save with a passphrase, Eclipse will prompt you for it each time you push or pull from your git remote server.
  • Close Git Bash

You can also use the GUI in the SSH2 Preference pane in Eclipse to manage hosts and keys.

2
  • I didn't have either of these, so I installed Git SCM from git-scm.com/download/win and then loaded the Git GUI in the project folder. This appears to have fixed the issue in Eclipse.
    – mrswadge
    Apr 10, 2014 at 8:35
  • similar issue for me, I had problems with the secure storage in eclipse/mac, deleting the GIT key resolved the problem
    – chrismarx
    Aug 13, 2014 at 11:57
2

Using Eclipse / Indigo, with the Maven plugin:

  • Check out Maven Projects from SCM

  • assuming that the git SCM plugin is installed, select "git" from the SCM URL: popup

  • enter, e.g.:

    https://<username>@github.com/<username>/<projectname>.git
    

    having @ and ".git" is important

  • assuming that the project is private, you will be prompted for the password

This should be good enough to move forward.

1
  • This is on the right track, actually. protocol: "git", url: "github.com/account/repo.git" may work for people who normally use https for their git operations. Nov 22, 2014 at 14:57
1

May be your git server has moved?

enter image description here

1
  • It was the perfect answer for me:) Mar 2, 2021 at 14:50
0

check out your .git/config this error can occur is your missing ".git" at the end of your origin url

[remote "origin"] url = https://some.domain.com/repo/name

should be

[remote "origin"] url = https://some.domain.com/repo/name.git

0

This Error may occur due to following reasons -

  1. Check the repository url, there should be a '.git' appended in the end.
  2. In case your network configurations have changed, make sure you have correct proxy configuration, and in case of secured git repository, make sure you provide correct credentials. (I got this error when my credentials were changed, and also when i had incorrect proxy configured.)

PS - To check network settings, go to Windows -> Preferences -> General -> Network Connections. Also if you're unsure of network settings or proxy config, you can try switching between Direct and Manual network settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.