无法从 Ubuntu 上的 bitbucket 克隆 repo

can't clone repo from bitbucket on Ubuntu

我正在尝试从 Ubuntu 上的 Bitbucket 克隆一个 repo,但它失败了:

fatal: https://user@bitbucket.org/owner/repo.git/info/refs not valid: is this a git repository?

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

我使用的命令是:

git clone https://user@bitbucket.org/owner/repo.git

Ubuntu 可能是什么问题?

我认为命令可以是 https

git clone https://bitbucket.org/owner/repo.git

或 ssh

git clone git@bitbucket.org:owner/repo.git

使用 ssh 协议代替 http/https .

使用 http/https 每次与服务器“对话”时都必须输入密码。

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

git clone git@bitbucket.org:owner/repo.git

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

Add the keys to your bitbucket account

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

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


注:

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