git 克隆一个私有的 bitbucket 存储库,允许我访问

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30737459/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:06:03  来源:igfitidea点击:

cloning a private bitbucket repository given access to me

gitclonebitbucket

提问by ehsanM

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

我需要从另一个用户授予我访问权限的 Bitbucket 克隆一个存储库。

I tried this:

我试过这个:

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

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

它给了我一条错误消息:Permission denied(publickey)

How I can clone this repository?

我如何克隆这个存储库?

回答by Yan Foto

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

克隆 git 项目时,您可以使用 SSH 或 HTTP 协议。请参阅文档

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.

您可以使用安全超文本传输​​协议 (HTTPS) 或安全外壳 (SSH) 连接到 Bitbucket。HTTPS 要求您在每次连接到 Bitbucket 服务器时输入用户名/密码,例如,当您推送更改时。HTTPS 适用于您不经常使用 Bitbucket 并且很少更改代码的情况。但是,如果您使用 Bitbucket 托管存储库完成大部分编码,则需要设置 SSH 连接。配置 SSH 后,Bitbucket 不再要求您使用用户名/密码组合对每个远程通信进行身份验证。

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

使用 SSH 时(就您而言),您需要在您的 BitBucket 帐户上安装公钥。请参阅此处了解更多信息。请注意,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!

这应该让你开始。不过我还没有测试过!

回答by Animesh Sharma

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 linkfor that repository. Copy that link and in your terminal type:

如果您能够访问 bitbucket.org 上的存储库,那么您肯定可以访问。转到 bitbucket.org 上的存储库。在右上角,您将找到该存储库的HTTP 克隆链接。复制该链接并在您的终端类型中输入:

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

为了避免一次又一次地输入用户名和密码,试试 这个