简体   繁体   English

克隆一个私有的 bitbucket 存储库来访问我

[英]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.我需要从另一个用户授予我访问权限的 Bitbucket 克隆一个存储库。

I tried this:我试过这个:

git clone myusername@bitbucket.org:repositoryOwnerUserName/repo.git

It gave me an error message: Permission denied(publickey) .它给了我一条错误消息: Permission denied(publickey)

How I can clone this repository?我如何克隆这个存储库?

When cloning a git project you can either use SSH or HTTP protocols.克隆 git 项目时,您可以使用 SSH 或 HTTP 协议。 See the documentation :请参阅文档

You can use either secure hypertext transport protocol (HTTPS) or secure shell (SSH) to connect to Bitbucket.您可以使用安全超文本传输​​协议 (HTTPS) 或安全外壳 (SSH) 连接到 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 要求您每次连接到 Bitbucket 服务器时输入用户名/密码,例如,当您推送更改时。 HTTPS is suitable for situations where you work with Bitbucket infrequently and make few code changes. HTTPS 适用于您不经常使用 Bitbucket 并且很少更改代码的情况。 However, if you do most of your coding with a Bitbucket hosted repository, you'll want to set up a SSH connection.但是,如果您使用 Bitbucket 托管存储库完成大部分编码,则需要设置 SSH 连接。 After you configure SSH, Bitbucket no longer requires you to authenticate each remote communication with a username/password combination.配置 SSH 后,Bitbucket 不再要求您使用用户名/密码组合对每个远程通信进行身份验证。

When using SSH (as it is in your case) you need to have you public key installed on your BitBucket account.使用 SSH 时(就像您的情况一样),您需要在您的 BitBucket 帐户上安装公钥。 See here for more info.请参阅此处了解更多信息。 Note that URLs for SSH method start with git@ and not username@ .请注意,SSH 方法的 URL 以git@而不是username@开头。

You can also try to clone it using the HTTP method, which in this case would be like:您还可以尝试使用 HTTP 方法克隆它,在这种情况下,它类似于:

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

This should get you started.这应该让你开始。 However I have not tested it!不过我还没有测试过!

If you are able to access the repository on bitbucket.org, then you sure have access.如果您能够访问 bitbucket.org 上的存储库,那么您肯定可以访问。 Go to the repository on bitbucket.org.转到 bitbucket.org 上的存储库。 On the top right side, you will find the HTTP clone link for that repository.在右上角,您将找到该存储库的HTTP 克隆链接 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.一旦你输入这些,repo 将被克隆到你的系统。

To save yourself from having to type username and password again and again, try this为了避免一次又一次地输入用户名和密码,试试这个

Currently (in 2022) to apply your SSH keys you have to use SSH+GIT protocol as follows:目前(2022 年)要应用您的 SSH 密钥,您必须使用 SSH+GIT 协议,如下所示:

git clone git+ssh://myusername@bitbucket.org/repositoryOwnerUserName/repo.git

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM