克隆或推送 git 存储库时,Eclipse 中出现“无法打开 git-upload-pack"错误 [英] 'cannot open git-upload-pack' error in Eclipse when cloning or pushing git repository

查看:51
本文介绍了克隆或推送 git 存储库时,Eclipse 中出现“无法打开 git-upload-pack"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在 Eclipse 中的 Bitbucket 中克隆或推送到 git 存储库:

I am not able to clone or push to a git repository at Bitbucket in Eclipse:

这很奇怪,因为前一天我没有任何问题.我已经下载了 sts 3 次,但都没有运气.这个错误一直显示.我还安装了 SourceTree,它说这不是有效的源路径/URL":

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':

如果我使用 git 命令导入项目,它可以工作,但我不想将 EGit 用于此任务,因为我是 git 的新手.

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.

我不知道这是否与它有关,但在同一目录中我有 android-adt-bundle.这个效果很好,但该项目位于 GitHub 而不是 Bitbucket.此外,我正在与另一个人合作,他能够从 Bitbucket 存储库中获取和推送数据.我已经阅读了很多帖子,但没有一个对我有帮助.

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.

顺便说一句,我使用的是 Windows 7.

I'm using Windows 7 btw.

推荐答案

由于 Eclipse 论坛中概述的步骤:

  1. 根据 http://help.github 上的 github 说明下载并安装 mysys git.com/win-git-installation/
  2. 在 C:/Users/you/ssh 中,隐藏子目录中的所有现有密钥(id_rsa 和 id_rsa.pub).如果 ssh 目录不存在,请创建它.当然,您"是您的用户名,因为操作系统知道您.
  3. 从开始菜单中,运行 Git-Bash 命令外壳(常规 DOS 命令外壳将不起作用).
  4. 在 Git-Bash shell 中,根据您的电子邮件(您在 github 上注册的那个)生成一个 rsa 密钥:ssh-keygen -t rsa -C "you@wherever.com"并输入您的密码短语并在询问时确认.
  5. 上一步应该已经创建了 C:/User/you/ssh/id_rsa.pub,您现在可以在文本编辑器中打开并复制它.在 github 上,转到帐户设置、SSH 密钥,添加一个密钥并将其粘贴到密钥框中.
  6. 再次在 Git-Bash 中(注意下一行的反引号):<代码>评估`ssh-agent`ssh 添加 C:/User/you/ssh/id_rsassh git@github.com

这是您刚刚执行的操作:您运行了 ssh-add 所需的 ssh-agent.然后您使用 ssh-add 记下您的密钥的位置.然后您尝试通过 ssh 连接到 GitHub.对最后一条命令的响应应该是您已在 GitHub 上成功通过身份验证,但您没有 shell 访问权限.这只是一个身份验证测试.如果身份验证不成功,您将不得不解决这个问题.尝试详细版本:

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 -v git@github.com

假设这有效....

  1. Window > Show View > Git > Git Repositories 将添加一个存储库浏览器窗口.
  2. 在存储库窗口中,选择存储库并展开并右键单击远程,然后选择创建远程.
  3. 从 GitHub 存储库页面复制 GitHub 存储库 URI 并将其粘贴到 URI 框中.
  4. 选择 ssh 作为协议,然后返回 URI 框并在开头添加git+",如下所示:

  1. Window > Show View > Git > Git Repositories will add a repository explorer window.
  2. In the repository window, select the repository and expand and right-click Remotes and choose Create Remote.
  3. Copy the GitHub repository URI from the GitHub repository page and paste it in the URI box.
  4. 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://git@github.com/UserName/ProjectName.git

git+ssh://git@github.com/UserName/ProjectName.git

Repository Path 框中,删除前导斜杠

In the Repository Path box, remove the leading slash

我没有使用 SSH git@github.com,而是使用 SSH git@bitbucket.org.

Instead of using SSH git@github.com I did it with SSH git@bitbucket.org.

现在我可以毫无问题地推送和导入了.

Now I can push and import without any problem.

这篇关于克隆或推送 git 存储库时,Eclipse 中出现“无法打开 git-upload-pack"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆