git 导入 Eclipse 时出现“Invalid remote: origin”错误(m2eclipse、eGit)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11525374/
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
"Invalid remote: origin" error when importing to Eclipse (m2eclipse, eGit)
提问by alex
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...
在 Eclipse 中,当我尝试从存储库导入项目(文件 > 导入 > Maven > 从 SCM 检出 Maven 项目)时,我选择“git”(已安装 eGit),填写 ssh://... 地址(所有密钥和访问权限已设置),最后输入 rsa 的密码和...
Invalid remote: origin: Invalid remote: origin
According to this: http://youtrack.jetbrains.com/issue/IDEA-77239writing .git
at the end of address should solve the problem but actually it does not.
根据这个:http: //youtrack.jetbrains.com/issue/IDEA-77239.git
在地址末尾写应该可以解决问题,但实际上并没有。
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.
编辑:我使用 Windows。这似乎是要添加的重要信息。
回答by Adam Keck
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.
当存在底层 SSH 身份验证问题时,可能会发生此错误,例如 git 远程服务器上的公钥错误,或者 git 远程服务器更改了其 SSH 主机密钥。
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\" .
Eclipse 将使用您在 Preferences -> General -> Network Connections -> SSH2 中指定的 .ssh 目录进行 ssh 配置。将其设置为 "{您的默认用户目录}.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.
要解决问题,首先您需要确定您为 Git 使用的是哪个 ssh 客户端。这存储在 GIT_SSH 环境变量中。右键单击“计算机”(Windows 7),然后选择属性 -> 高级系统设置 -> 环境变量。
If GIT_SSH contains a path to plink.exe, you are using the PuTTY stack.
如果 GIT_SSH 包含 plink.exe 的路径,则您使用的是 PuTTY 堆栈。
- 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.
- 要获取您的公钥,请打开 PuTTYgen.exe,然后加载您的私钥文件 (*.ppk)。列出的公钥应该与 git 远程服务器上的公钥匹配。
- 要获取新的主机密钥,请打开一个新的 PuTTY.exe 会话,然后连接到 git@{git repo host}。
- 单击“确定”并说“是”以存储新密钥。
- 收到登录提示后,您可以关闭 PuTTY 窗口。新密钥已存储。
- 重新启动 Eclipse。
If GIT_SSH contains a path to "ssh.exe" in your "Git for Windows" tree, you are using Git for Windows's OpenSSH.
如果 GIT_SSH 在您的“Git for Windows”树中包含“ssh.exe”的路径,则您正在使用 Git for Windows 的 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.
- 将 %HOME% 设置为您的默认用户目录(如 Eclipse 中所列;见上文)。
- 将 %HOMEDRIVE% 设置为默认用户目录的驱动器号。
- 将 %HOMEPATH% 设置为 %HOMEDRIVE% 上默认用户目录的路径
- 要获取您的公钥,请在文本编辑器中打开文件 %HOMEDRIVE%%HOMEPATH%/.ssh/id_rsa.pub(或 id_dsa.pub)。列出的公钥应该与 git 远程服务器上的公钥匹配。
- 要获取新的主机密钥,请运行:cmd.exe
- 运行 Git Bash
- Ctrl-C
- 在 bash 提示符下,运行 /c/path/to/git/for/windows/bin/ssh.exe git@{git remote host}。
- 键入 yes 以接受新密钥。
- 出现登录提示后,键入: ctrl-c
- 关闭 cmd.exe 窗口
- 重新启动 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.
最后,如果您的外部 ssh 客户端仍然有问题,请删除 GIT_SSH 环境变量并将 HOME 环境变量设置为您在 Windows 上的默认用户目录。如果没有 GIT_SSH 变量,EGit 将使用其内部 ssh 客户端 (java)。它将使用您在上面指定的 .ssh 目录作为其 SSH 配置目录。
Note: If you have Git for Windows, you can use its tools to create a SSH key pair your .ssh directory:
注意:如果你有适用于 Windows 的 Git,你可以使用它的工具在你的 .ssh 目录中创建一个 SSH 密钥对:
- 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
- 将 %HOME% 设置为您的默认用户目录(如 Eclipse 中所列)。
- 将 %HOMEDRIVE% 设置为默认用户目录的驱动器号。
- 将 %HOMEPATH% 设置为 %HOMEDRIVE% 上默认用户目录的路径
- 运行 Git Bash
- Ctrl -C
- 运行:ssh-keygen.exe -t rsa -b 2048
- 保存为默认文件名
- 选择一个密码或不保存。如果您使用密码保存,每次从 git 远程服务器推送或拉取时,Eclipse 都会提示您输入密码。
- 关闭 Git Bash
You can also use the GUI in the SSH2 Preference pane in Eclipse to manage hosts and keys.
您还可以使用 Eclipse 中 SSH2 Preference 窗格中的 GUI 来管理主机和密钥。
回答by Martin Haeberli
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://@github.com//.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.
使用 Eclipse/Indigo 和 Maven 插件: -
从 SCM 中查看 Maven 项目 -
假设安装了 git SCM 插件,从 SCM URL 中选择“git”:popup
-enter,例如 https://@github.com //.git
有 @ 和 ".git" 很重要——
假设项目是私有的,你会被提示输入密码
这应该足以让你继续前进。
回答by Reece Markowsky
check out your .git/config this error can occur is your missing ".git" at the end of your origin url
检查你的 .git/config 这个错误可能发生是你的原始 url 末尾缺少“.git”
[remote "origin"] url = https://some.domain.com/repo/name
[远程“来源”] url = https://some.domain.com/repo/name
should be
应该
[remote "origin"] url = https://some.domain.com/repo/name.git
[远程“来源”] url = https://some.domain.com/repo/name.git
回答by shashi009
This Error may occur due to following reasons -
由于以下原因,可能会发生此错误 -
- Check the repository url, there should be a '.git' appended in the end.
- 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.)
- 检查存储库 url,最后应该附加一个“.git”。
- 如果您的网络配置发生了变化,请确保您有正确的代理配置,如果是安全的 git 存储库,请确保您提供正确的凭据。(当我的凭据被更改时,以及当我配置了不正确的代理时,我收到了这个错误。)
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.
PS - 要检查网络设置,请转到 Windows -> 首选项 -> 常规 -> 网络连接。此外,如果您不确定网络设置或代理配置,您可以尝试在直接和手动网络设置之间切换。