git 无法使用 EGit 和 Bitbucket 推送
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13481935/
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
Can't push using EGit and Bitbucket
提问by EmilioSG
I've been trying to start a project using EGit with Bitbucket but I can't push the project to the repository in the server.
我一直在尝试使用 EGit 和 Bitbucket 启动一个项目,但我无法将项目推送到服务器中的存储库。
These are the steps I've followed (I'll try to be very specific so other people can use it as a tutorial mode; even though it's not working for me it might work for others):
这些是我遵循的步骤(我将尝试非常具体,以便其他人可以将其用作教程模式;即使它对我不起作用,但可能对其他人有用):
1) I installed Git on Ubuntu 12.10 using this tutorial
1) 我使用本教程在 Ubuntu 12.10 上安装了 Git
2) Followed this tutorialfor GitHub.
2)按照 GitHub 的本教程进行操作。
- Start a new C++ project in Eclipse
- Under Window > Preferences > General > Network Connection > SSH2 > Key Management tab, I generated a new RSA key and added it to the list of deployment keys of my repository on Bitbucket.
- Right click on the eclipse project: Team > Share project ; Team > Add to index ; Team > Commit
- Window > Show View > Other > Git > Git Repositories
- Right click on Remotes > Create Remote > Checked "Configure push" and typed my project's name
- Add Push URL:
ssh://[email protected]/myuser/myrepository.git
, Protocol: ssh; port: blank; user: git; password: blank - Advanced button under Ref mappings and selected the "master" version. If this step works, it means that the RSA key is configured in Bitbucket and EGit properly. Otherwise it will show a connection error.
- 在 Eclipse 中启动一个新的 C++ 项目
- 在“窗口”>“首选项”>“常规”>“网络连接”>“SSH2”>“密钥管理”选项卡下,我生成了一个新的 RSA 密钥并将其添加到我在 Bitbucket 上的存储库的部署密钥列表中。
- 右键单击eclipse项目:Team > Share project;团队 > 添加到索引;团队 > 提交
- 窗口 > 显示视图 > 其他 > Git > Git 存储库
- 右键单击 Remotes > Create Remote > 选中“配置推送”并输入我的项目名称
- 添加推送 URL:
ssh://[email protected]/myuser/myrepository.git
, 协议: ssh; 端口:空白;用户: git; 密码:空白 - 参考映射下的高级按钮并选择了“主”版本。如果此步骤有效,则说明在 Bitbucket 和 EGit 中正确配置了 RSA 密钥。否则会显示连接错误。
Everything is done. However, when I press "Push" I get the following error:
一切都完成了。但是,当我按“推送”时,出现以下错误:
ssh://[email protected]/myuser/myrepository.git: push not permitted
I've tried every configuration possible: switched to a new work space, updated Eclipse, created new repositories, re-installed Git... Any ideas?
我已经尝试了所有可能的配置:切换到一个新的工作空间,更新 Eclipse,创建新的存储库,重新安装 Git ......有什么想法吗?
回答by EmilioSG
Alright, I've finally found a way to work with it.
好吧,我终于找到了一种方法来处理它。
It's just changing the authentication mode. If the HTTPS link is used, instead of using the SSH link, everything works perfectly. It seems that SSH works just in a read-only mode.
这只是改变身份验证模式。如果使用 HTTPS 链接,而不是使用 SSH 链接,则一切正常。SSH 似乎只是在只读模式下工作。
Of course the authentication method is different: you have to type the password and the SSH keys stored in Bitbucket are no longer necessary.
当然认证方式不同:你必须输入密码,并且不再需要存储在 Bitbucket 中的 SSH 密钥。
For those who are having problems with EGit, I recommend following eugener's way to automatically configure EGit. Then you just have to select HTTPS as authentication mode to push the stored commits.
对于那些在使用 EGit 时遇到问题的人,我建议按照 eugener 的方式自动配置 EGit。然后你只需要选择 HTTPS 作为身份验证模式来推送存储的提交。
回答by Eugene Ryzhikov
There is much simpler way
of configuring remote Git repos in Eclipse:
还有much simpler way
在Eclipse中配置远程的Git回购:
- Create an empty repo on BitBicket
- Copy repo's URL
- Clone repo to your machine using "Git Repositories" view.
- Share your project into newly cloned repo.
- 在 BitBicket 上创建一个空仓库
- 复制 repo 的 URL
- 使用“Git 存储库”视图将存储库克隆到您的机器上。
- 将您的项目共享到新克隆的存储库中。
Since a repo was cloned - remote settings were configured automatically. This means you will be able to push immediately
由于一个 repo 被克隆 - 远程设置是自动配置的。这意味着您将能够立即推送
回答by Mark Leighton Fisher
It might be a user name misconfiguration in .gitconfig.
这可能是.gitconfig 中的用户名配置错误。
回答by chrizzler
Probably related, I fixed "auth fail" problems by following the instructions on: http://wangpidong.blogspot.com.es/2012/05/how-to-use-bitbucket-with-egit-in.html
可能相关,我按照以下说明修复了“身份验证失败”问题:http: //wangpidong.blogspot.com.es/2012/05/how-to-use-bitbucket-with-egit-in.html
Got it from: Configuring egit with BitBucket
回答by Greg Dubicki
In this specific case I agree with resolution from Olivier J.'scomment under original question.
在这种特定情况下,我同意Olivier J.在原始问题下的评论的解决方案。
But I have had similar problem and it was caused by something else. I resolved it and here is what happened:
但是我遇到了类似的问题,这是由其他原因引起的。我解决了它,这是发生的事情:
I have been using some privaterepository at Bitbucket (A) with some user account and some public key (X) to access it. I have had key X loaded in my
pageant
Putty key chain.Then I created a new publicrepository (B), also at Bitbucket with a different user account and another public key (Y). I added this key to
pageant
too.When I tried to access repository B apparently public key X and not Y was used, because ..for SSH client both connections are the same - same user (git) at the same host (bitbucket.org)! And key X was used first because ..it was loaded earier? Or maybe because its name was alphabetically first? I am not sure but the result was that...
Read-only access for B using X was grantedbecause the repository was public and any valid Bitbucket user key was enough to gain this kind of access!
..but writing (pushing) required key Y, which was not used by SSH.
我一直在 Bitbucket (A) 上使用一些私有存储库,其中包含一些用户帐户和一些公钥 (X) 来访问它。我已经在我的
pageant
Putty 钥匙链中加载了钥匙 X。然后我创建了一个新的公共存储库 (B),也在 Bitbucket 使用不同的用户帐户和另一个公钥 (Y)。我也添加了这个键
pageant
。当我尝试访问存储库 B 时,显然使用了公钥 X 而不是 Y,因为 .. 对于 SSH 客户端,两个连接都是相同的 - 同一主机(bitbucket.org)上的同一用户(git)!并且首先使用键 X 是因为 .. 它被加载得更早?或者也许是因为它的名字是按字母顺序排列的?我不确定,但结果是......
授予B 使用 X 的只读访问权限,因为存储库是公开的,并且任何有效的 Bitbucket 用户密钥都足以获得这种访问权限!
..但写入(推送)需要密钥 Y,SSH 未使用该密钥。
So the general tip is: to resolve strange read-only git via SSH access errors check carefully which private key is actually used by SSH.
所以一般提示是:通过 SSH 访问错误解决奇怪的只读 git 仔细检查 SSH 实际使用哪个私钥。
I resolved this problem by loading only one key - X or Y - in pageant
at a time but I would love to do it a smarter way - please let me know in comments if you know how!
我通过一次只加载一个键 - X 或 Y - 解决了这个问题,pageant
但我想以更聪明的方式来做 - 如果你知道怎么做,请在评论中告诉我!
回答by dexter
Using Bitbucket I do it this way:
使用 Bitbucket 我这样做:
- create a repository in bitbucket
- clone the empty repository using the https url
- connect the project in eclipse to the repository using the Team -> Share option and select the location where you cloned the repo
- index (stage) your project files
- commit and push
- 在 bitbucket 中创建存储库
- 使用 https url 克隆空存储库
- 使用 Team -> Share 选项将 eclipse 中的项目连接到存储库,然后选择克隆存储库的位置
- 索引(阶段)您的项目文件
- 提交和推送