Search code examples
gitclonebitbucket

cloning a private bitbucket repository given access to me


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?


Solution

  • 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!