克隆或推送 git 存储库时,Eclipse 中出现“无法打开 git-upload-pack”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18813847/
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
'cannot open git-upload-pack' error in Eclipse when cloning or pushing git repository
提问by kiduxa
I am not able to clone or push to a git repository at Bitbucket in Eclipse:
我无法在 Eclipse 中的 Bitbucket 中克隆或推送到 git 存储库:
It's weird, because a day before I didn't have any problem. I have downloaded the sts 3 times with no luck. This error keeps showing. Also I have installed SourceTree and it says 'This is not a valid source path / URL':
这很奇怪,因为前一天我没有任何问题。我已经下载了 sts 3 次,但没有成功。这个错误一直显示。我还安装了 SourceTree,它说“这不是有效的源路径/URL”:
If I use git commands to import the project, it works, but I wan't to use EGit for this task, since I am a newbie with git.
如果我使用 git 命令导入项目,它可以工作,但我不想将 EGit 用于此任务,因为我是 git 的新手。
I don't know if this has to do with it, but in the same directory I have the android-adt-bundle. This one works pretty well, but the project lies on GitHub and not Bitbucket. Also, I'm working with another person and he is able to fetch and push data from and to the Bitbucket repository. I have read lots of posts but none of them have helped me out.
我不知道这是否与它有关,但在同一目录中我有 android-adt-bundle。这个工作得很好,但该项目位于 GitHub 而不是 Bitbucket。此外,我正在与另一个人合作,他能够从 Bitbucket 存储库中获取和推送数据。我已经阅读了很多帖子,但没有一个对我有帮助。
I'm using Windows 7 btw.
顺便说一句,我正在使用 Windows 7。
采纳答案by kiduxa
Finally I made it work thanks to the steps outlined in the Eclipse forum:
最后,由于Eclipse 论坛中概述的步骤,我使它工作:
Set up the SSH key stuff
设置 SSH 密钥的东西
- Download and install mysys git according to the github instructions at http://help.github.com/win-git-installation/
- In C:/Users/you/ssh hide any existing keys (id_rsa and id_rsa.pub) in a subdirectory. If the ssh directory does not exist, create it. Of course, "you" is your username as the OS knows you.
- From the start menu, run Git-Bash command shell (a regular DOS command shell will not work).
- In the Git-Bash shell generate an rsa key based on your email (the one you registered at github): ssh-keygen -t rsa -C "[email protected]" and enter your pass phrase and confirm when asked.
- The previous step should have created C:/User/you/ssh/id_rsa.pub which you can now open in a text editor and copy. At github, go to account settings, SSH Keys, add a key and paste this in the key box.
- In Git-Bash again (notice the back-ticks in the next line):
eval `ssh-agent` ssh-add C:/User/you/ssh/id_rsa ssh [email protected]
- 根据http://help.github.com/win-git-installation/上的 github 说明下载并安装 mysys git
- 在 C:/Users/you/ssh 中,隐藏子目录中的所有现有密钥(id_rsa 和 id_rsa.pub)。如果 ssh 目录不存在,请创建它。当然,“您”是您的用户名,因为操作系统知道您。
- 从开始菜单,运行 Git-Bash 命令外壳(常规 DOS 命令外壳将不起作用)。
- 在 Git-Bash shell 中根据您的电子邮件(您在 github 上注册的那个)生成一个 rsa 密钥: ssh-keygen -t rsa -C "[email protected]" 并输入您的密码短语并在询问时确认。
- 上一步应该已经创建了 C:/User/you/ssh/id_rsa.pub,您现在可以在文本编辑器中打开并复制它。在 github 上,转到帐户设置,SSH 密钥,添加一个密钥并将其粘贴到密钥框中。
- 再次在 Git-Bash 中(注意下一行的反引号):
eval `ssh-agent` ssh-add C:/User/you/ssh/id_rsa ssh [email protected]
Here is what you just did: You ran the ssh-agent which is needed by ssh-add. Then you used ssh-add to make note of the location of your key. Then you tried to ssh to GitHub. The response to this last command should be that you have successfully authenticated at GitHub but that you don't have shell access. This is just an authentication test. If the authentication was not successful, you'll have to sort that out. Try the verbose version:
这是您刚刚执行的操作:您运行了 ssh-add 所需的 ssh-agent。然后您使用 ssh-add 记下您的密钥的位置。然后您尝试通过 ssh 连接到 GitHub。对最后一条命令的响应应该是您已在 GitHub 上成功通过身份验证,但您没有 shell 访问权限。这只是一个身份验证测试。如果身份验证不成功,您将不得不解决这个问题。尝试详细版本:
ssh -v [email protected]
ssh -v [email protected]
Assuming this worked....
假设这有效......
In Eclipse, configure the remote push
在Eclipse中,配置远程推送
- Window> Show View> Git> Git Repositorieswill add a repository explorer window.
- In the repository window, select the repository and expand and right-click Remotesand choose Create Remote.
- Copy the GitHub repository URI from the GitHub repository page and paste it in the URI box.
Select ssh as the protocol but then go back to the URI box and add "git+" at the beginning so it looks like this:
git+ssh://[email protected]/UserName/ProjectName.git
In the Repository Pathbox, remove the leading slash
- Hit Nextand cross your fingers. If your get "auth fail", restart Eclipse and try step 5 again.
- When you get past the authentication, in the next dialog select "master" for source ref, click "Add all branches spec" and "Finish".
- Window> Show View> Git> Git Repositories将添加一个存储库浏览器窗口。
- 在存储库窗口中,选择存储库并展开并右键单击Remotes并选择Create Remote。
- 从 GitHub 存储库页面复制 GitHub 存储库 URI 并将其粘贴到 URI 框中。
选择 ssh 作为协议,然后返回 URI 框并在开头添加“git+”,如下所示:
git+ssh://[email protected]/UserName/ProjectName.git
在Repository Path框中,删除前导斜杠
- 点击下一步并交叉手指。如果您得到“身份验证失败”,请重新启动 Eclipse 并再次尝试步骤 5。
- 当您通过身份验证时,在下一个对话框中为源引用选择“主”,单击“添加所有分支规范”和“完成”。
Instead of using SSH [email protected] I did it with SSH [email protected].
我没有使用 SSH [email protected],而是使用 SSH [email protected]。
Now I can push and import without any problem.
现在我可以毫无问题地推送和导入。
回答by NextThursday
Might also be bad SSL cert, fix the server
也可能是错误的 SSL 证书,修复服务器
If you have a GIT server with an outdated or self-signed SSL cert fix the server, afterwards everything should run fine.
如果您的 GIT 服务器带有过时的或自签名的 SSL 证书,请修复该服务器,之后一切都应该正常运行。
Insecure Hotfix: Let the client accept any certificate
不安全修补程序:让客户端接受任何证书
The following solution is just a mere hotfix on client side and should be avoided as it compromises securityof your credentials and content. There is a detailed explanation for this in "How can I make git accept a self signed certificate?" which offers more complex and more secure solutions you can try out if the following works in general.
以下解决方案仅仅是客户端的修补程序,应避免使用,因为它会危及您的凭据和内容的安全性。在“我如何让 git 接受自签名证书?”中有对此的详细解释,其中提供了更复杂和更安全的解决方案,如果以下内容一般有效,您可以尝试。
In my case it was Eclipse using a different storage for the git config as the command line does and thus not having the option
在我的情况下,Eclipse 为 git 配置使用不同的存储作为命令行,因此没有选项
git config http.sslVerify false
set (which I set using command line for the repo for working with invalid/untrusted SSL cert).
设置(我使用命令行为 repo 设置,用于处理无效/不受信任的 SSL 证书)。
Adding the option insides Eclipse immediately resolves the issue. To add the option
在 Eclipse 中添加该选项可立即解决该问题。添加选项
- open preferences via application menu Window => Preferences(or on OSX Eclipse => Settings).
- Navigate to Team => Git => Configuration
- click
Add entry...
, then puthttp.sslVerify
in the key box andfalse
in the value box.
- 通过应用程序菜单Window => Preferences(或在 OSX Eclipse => Settings上打开首选项)。
- 导航到团队 => Git => 配置
- 单击
Add entry...
,然后放入http.sslVerify
键框和false
值框。
Seems to be a valid solution for Eclipse 4.4 (Luna), 4.5.x (Mars) and 4.6.x (Neon) on different Operating systems.
似乎是适用于不同操作系统上的 Eclipse 4.4 (Luna)、4.5.x (Mars) 和 4.6.x (Neon) 的有效解决方案。
回答by Sireesh Yarlagadda
It happens due to the following Reasons:
它的发生是由于以下原因:
1) Firewall.
1) 防火墙。
2) Network Issues.
2) 网络问题。
3) Proxy Settings Mismatch
3) 代理设置不匹配
4) Connected through different Router - which is not authorized within the network.
4)通过不同的路由器连接 - 这在网络内未经授权。
5) Git Proxy Authentication Details
5) Git 代理认证详情
回答by Aaron Axvig
One cause of this is having Fiddler2 configured to decrypt HTTPS traffic. Close Fiddler2 and it should work fine.
造成这种情况的一个原因是将 Fiddler2 配置为解密 HTTPS 流量。关闭 Fiddler2,它应该可以正常工作。
回答by Radouane ROUFID
After struggling for a couple of hours, I found that git config file was not updated when I added the entry sslVerify = false
in my Eclipse.
经过几个小时的努力,我发现当我sslVerify = false
在 Eclipse 中添加条目时,git 配置文件没有更新。
I solved my problem by navigating to my .git
directory and updating the config
file to :
我通过导航到我的.git
目录并将config
文件更新为解决了我的问题:
[http]
sslVerify = false
回答by liox
I added -Dhttps.protocols=TLSv1.1,TLSv1.2
to eclipse.ini
and it's working.
I use java 1.7
我添加-Dhttps.protocols=TLSv1.1,TLSv1.2
到eclipse.ini
它的工作。我使用 java 1.7
回答by user560663
This issue can be caused when you have a local firewall which is preventing your application from being able to send any network traffic away from your machine. I.e. Outbound traffic or egress traffic rules.
当您有本地防火墙阻止您的应用程序能够将任何网络流量发送到您的机器之外时,可能会导致此问题。即出站流量或出口流量规则。
Please try disabling your firewall for a quick test to see if this fixes your issue. If it does then setup the appropriate firewall policy for the application you are trying to use to push or pull to a git repository.
请尝试禁用防火墙以进行快速测试,看看这是否能解决您的问题。如果确实如此,则为您尝试用于推送或拉取到 git 存储库的应用程序设置适当的防火墙策略。
回答by iTake
In my case, it turned out that global proxy settings in "Preferences->Network connections" were interfering with git. Which is kind of confusing, because git has dedicated property for proxy configuration. Anyway, I've added repository host to "Proxy bypass" list and the problem was gone.
就我而言,事实证明“首选项->网络连接”中的全局代理设置干扰了 git。这有点令人困惑,因为 git 具有用于代理配置的专用属性。无论如何,我已将存储库主机添加到“代理绕过”列表中,问题就消失了。
回答by Hardik Lotiya
Recently I got same problem with existing repository.when I try to fetch from upstream not able Fetched object and got problems eclipse: cannot open git-upload-pack.
最近我在现有存储库中遇到了同样的问题。当我尝试从上游获取时无法获取对象并遇到问题 eclipse: cannot open git-upload-pack。
for me following solution work after adding TLS version in eclipse.inifile
对我来说,在eclipse.ini文件中添加 TLS 版本后,以下解决方案工作
Dhttps.protocols=TLSv1.1,TLSv1.2
Dhttps.protocols=TLSv1.1,TLSv1.2
For java7 need to add TLSv1.1 and for java8 need to TLSv1.2
java7需要添加TLSv1.1,java8需要TLSv1.2
Note: Need to restart eclipse once above configuration added.
注意:添加上述配置后需要重新启动eclipse。
回答by Dmytro Pastovenskyi
I got same problem when I got new laptop with Windows8/Kaspesky installed on it. I got problems eclipse: cannot open git-upload-pack. I also got problems with maven. I also got problem with Skype.
当我安装了 Windows8/Kaspesky 的新笔记本电脑时,我遇到了同样的问题。我遇到了 Eclipse 问题:无法打开 git-upload-pack。我也遇到了 maven 的问题。我也遇到了 Skype 问题。
When I disabled Kaspersky everything started to work properly.
当我禁用卡巴斯基时,一切都开始正常工作。