Can't push using EGit and Bitbucket

2019-03-18 20:38发布

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.

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

2) Followed this tutorial for 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://git@bitbucket.org/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.

Everything is done. However, when I press "Push" I get the following error:

ssh://git@bitbucket.org/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?

6条回答
一夜七次
2楼-- · 2019-03-18 20:48

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

Got it from: Configuring egit with BitBucket

查看更多
Root(大扎)
3楼-- · 2019-03-18 20:50

Using Bitbucket I do it this way:

  1. create a repository in bitbucket
  2. clone the empty repository using the https url
  3. connect the project in eclipse to the repository using the Team -> Share option and select the location where you cloned the repo
  4. index (stage) your project files
  5. commit and push
查看更多
SAY GOODBYE
4楼-- · 2019-03-18 20:56

In this specific case I agree with resolution from Olivier J.'s comment under original question.

But I have had similar problem and it was caused by something else. I resolved it and here is what happened:

  1. I have been using some private repository 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.

  2. Then I created a new public repository (B), also at Bitbucket with a different user account and another public key (Y). I added this key to pageant too.

  3. 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...

  4. Read-only access for B using X was granted because the repository was public and any valid Bitbucket user key was enough to gain this kind of access!

  5. ..but writing (pushing) required key Y, which was not used by 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.

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!

查看更多
一纸荒年 Trace。
5楼-- · 2019-03-18 21:01

There is much simpler way of configuring remote Git repos in Eclipse:

  1. Create an empty repo on BitBicket
  2. Copy repo's URL
  3. Clone repo to your machine using "Git Repositories" view.
  4. Share your project into newly cloned repo.

Since a repo was cloned - remote settings were configured automatically. This means you will be able to push immediately

查看更多
劫难
6楼-- · 2019-03-18 21:01
我欲成王,谁敢阻挡
7楼-- · 2019-03-18 21:09

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.

SSH/HTTPS selection

Of course the authentication method is different: you have to type the password and the SSH keys stored in Bitbucket are no longer necessary.

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.

查看更多
登录 后发表回答