Bitbucket + XCode 4.2 + Git

2019-01-17 07:28发布

I've been looking for a solution with Bitbucket and XCode.

As everybody knows, XCode 4.2 comes with git support. I've created a bitbucket account and I wanted to push my changes to my repository,

I've followed this tutorial https://confluence.atlassian.com/display/BITBUCKET/Use+the+SSH+protocol+with+Bitbucket

However this is the problem I'm facing. When I'm in the Organizer - Repositories Section at XCode, I go to my remotes folder and create a repository.

ssh://git@bitbucket.org/username/myrepo.git

However when I'm asked for Name and password, the ones I provide as username and password fails. I've also tried with git as a user but no luck.

UPDATE:

I've created a ~/.ssh/config file where I've added a specific configuration for bitbucket.

Host bitbucket.org
HostName bitbucket.org
IdentityFile ~/.ssh/bitbucket
User username

I've tested it with ssh -T git@bitbucket.org and It works, it gets authenticated.

However, when I test this with XCode I got the following error. "Authentication failed because the name or password was incorrect."

I know I'm missing something here.

UPDATE 2:

I've managed to solve the issue but only from command line, not from XCode. I'll post my solution later but feel free if you have a way to do it from XCode

Thanks

10条回答
Explosion°爆炸
2楼-- · 2019-01-17 08:05

You have to add your generated SSH key to your account.

I use GitHub, but BitBucket is basically a clone of it so the same procedures apply:

cat ~/.ssh/id_rsa.pub | pbcopy

Now try re-connecting.

查看更多
Root(大扎)
3楼-- · 2019-01-17 08:08

You can solve this problem in XCode without going to command line. You had everything right in your question but you set the URL up wrong.

It should be: git@bitbucket.org:username/myrepo.git

Instead of what you had: ssh://git@bitbucket.org/username/myrepo.git

查看更多
时光不老,我们不散
4楼-- · 2019-01-17 08:08

I was able to get XCode to accept and use my SSH key I had previously set up with Bitbucket by specifying git as the username (in the XCode UI), and putting my password, and my Bitbucket username goes in the URL of the repo.

Had to mess around with it a few times before it started working.

查看更多
Juvenile、少年°
5楼-- · 2019-01-17 08:11

I know there already are several answers, but I couldn't seem to get it working for me until one hour, so maybe I'm helping out someone out there.

My solution was simply to add my username to https://bitbucket.org/USERNAME/PROJECT_NAME/admin/access as an admin so then I could just normally type into Xcode as URL https://USERNAME@bitbucket.org/USERNAME/PROJECT_NAME.git with my username and password.

IMPORTANT: USERNAME stands for the user HOSTING the project, so if you're working on the repo of your colleague, this will be his username.

Hope this helps.

查看更多
beautiful°
6楼-- · 2019-01-17 08:13

Removing the username did not work for me. But I was able to solve the issue by adding my password like this to the URL:

https://username:password@bitbucket.org/username/myrepo.git

查看更多
We Are One
7楼-- · 2019-01-17 08:14

Ok It looks like I couldn't make it through the XCode Client.

However, the command line is the only way I managed to push my changes, and XCode only helped me to set the remote repository and add the credentials.

Finally what I've just needed to do is :

$git push myrepo master

And I got a success message:

Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 360 bytes, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: bb/acl: username is allowed. accepted payload.
To ssh://git@bitbucket.org/username/myrepo.git
 123abcd..5a12a67  master -> master
查看更多
登录 后发表回答