cloning a private bitbucket repository given access to me
Asked Answered
N

3

9

I need to clone a repository from Bitbucket that I was given access to by another user.

I tried this:

git clone [email protected]:repositoryOwnerUserName/repo.git

It gave me an error message: Permission denied(publickey).

How I can clone this repository?

Name answered 9/6, 2015 at 16:12 Comment(0)
O
10

When cloning a git project you can either use SSH or HTTP protocols. See the documentation:

You can use either secure hypertext transport protocol (HTTPS) or secure shell (SSH) to connect to Bitbucket. HTTPS requires you to enter a username/password each time you connect to the Bitbucket server, for example, when you push your changes. HTTPS is suitable for situations where you work with Bitbucket infrequently and make few code changes. However, if you do most of your coding with a Bitbucket hosted repository, you'll want to set up a SSH connection. After you configure SSH, Bitbucket no longer requires you to authenticate each remote communication with a username/password combination.

When using SSH (as it is in your case) you need to have you public key installed on your BitBucket account. See here for more info. Note that URLs for SSH method start with git@ and not username@.

You can also try to clone it using the HTTP method, which in this case would be like:

git clone http://bitbucket.org:repositoryOwnerUserName/repo.git

This should get you started. However I have not tested it!

Oxymoron answered 9/6, 2015 at 16:20 Comment(3)
Additionally, SSH cloning uses [email protected]:..., not [email protected]:....Grobe
That worked for me. Thanks. My problem was that I re-setup the SSH for my workstation and it works fine now. Thank you @YanFotoName
@YanFoto, May I ask another question too? Now the repository has several branches but the git pulls only the main branch. How I can pull all the branches all together? or I should clone them one b one? BTW I tried git pull --all but did not work for meName
J
5

If you are able to access the repository on bitbucket.org, then you sure have access. Go to the repository on bitbucket.org. On the top right side, you will find the HTTP clone link for that repository. Copy that link and in your terminal type:

git clone <link>

You will be asked for your username and password. Once you enter those, the repo will be cloned to your system.

To save yourself from having to type username and password again and again, try this

Jamisonjammal answered 9/6, 2015 at 16:40 Comment(0)
C
1

Currently (in 2022) to apply your SSH keys you have to use SSH+GIT protocol as follows:

git clone git+ssh://[email protected]/repositoryOwnerUserName/repo.git
Crocoite answered 18/3, 2022 at 22:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.