无法在Ubuntu上克隆来自bitbucket的repo

Lar*_*ell 3 git ubuntu bitbucket

我试图在Ubuntu上克隆来自Bitbucket的回购,它失败了:

fatal: https://user@bitbucket.org/owner/repo.git/info/refs not valid: is this a git repository?
Run Code Online (Sandbox Code Playgroud)

但是,如果我在我的Mac上执行完全相同的命令,它工作正常.

我使用的命令是:

git clone https://user@bitbucket.org/owner/repo.git
Run Code Online (Sandbox Code Playgroud)

在Ubuntu上可能出现什么问题?

Cod*_*ard 5

使用ssh协议而不是http/https.

使用http/https,每次必须与服务器"对话"时都必须输入密码.

使用ssh将使用ssh keys,您不必每次都输入用户名密码.

git clone git@bitbucket.org:owner/repo.git
Run Code Online (Sandbox Code Playgroud)

Permission denied (publickey)

您收到此错误,因为您的任何平台上都没有ssh密钥.设置密钥,将它们添加到您的帐户,您就可以了.


Create ssh keys

# create the key pair.
ssh-keygen -t rsa

# echo the key (pub) to the screen and copy it to clipboard
cat ~/.ssh/id_rsa.pub
Run Code Online (Sandbox Code Playgroud)

Add the keys to your bitbucket account

  • 登录您的Bitbucket帐户
    从应用程序菜单中选择头像>设置.

  • 选择SSH密钥并粘贴您从第一步复制的密钥

在此输入图像描述


注意:

在需要连接到帐户的每台计算机上重复此步骤,或将相同的密钥复制到所有计算机上.两种方式都有效.