我无法克隆一个Git存储库,并得到这个错误:

krishna.soni@KRISHNACHANDRAS /c/Projects $ git clone http://stage.abc.com:10088/pqr
http://<url>/<repository> Cloning into '<repository>'... fatal: could not read Username for 'http://<url>': No such file or directory

我读过Bitbucket, Windows和“致命:无法读取密码”,但仍然有问题。

我继续前进,但现在得到这个错误

sh.exe": chown: command not found

krishna.soni@KRISHNACHANDRAS /c
$ git clone ssh://krishna.sonipayu.in@stage.payupaisa.
/projects
Cloning into 'C:/projects'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

> krishna.soni@KRISHNACHANDRAS /c
>     $ git clone ssh:<url>
>     ts
>     Cloning into 'C:/projects'...
>     Permission denied (publickey).
>     fatal: Could not read from remote repository.

Please make sure you have the correct access rights

并且存储库存在。


当前回答

我也有类似的问题。我更改了ssh密钥并重新启动并尝试了所有其他“n”解决方案。但对我来说,真正的问题是我们的gitlab默认协议从ssh变成了https。

检查远程url

git remote -v

更改远程url

git remote set-url origin https://URL

其他回答

我在GitHub上也遇到了同样的问题。下面是解决方法!

在您的计算机上生成一个SSH密钥,如下所述:生成SSH密钥。 登录您的GitHub帐户:GitHub Login。 在您的帐号中添加新生成的“SSH Key: My account SSH Key”。 再次尝试git克隆项目。

您需要执行ssh-keygen -t rsa命令创建新的ssh密钥。

我一直面临着同样的问题,突然间我突然想到哪里会出问题。

在您的计算机上生成一个SSH密钥,如下所述:生成 SSH密钥。

这就是我做错的地方

在生成ssh密钥时使用下面的命令,但我没有使用sudo,而克隆时我使用的是“sudo git克隆ssh_repo_url”,因为克隆时我需要创建我的用户没有权限的文件夹

生成ssh的错误方法

$ ssh-keygen -t ed25519 -C "your_email@example.com"

正确的方法,如果在克隆时使用sudo

$ sudo ssh-keygen -t ed25519 -C "your_email@example.com"

登录您的GitHub帐户:GitHub Login。 在您的帐号中添加新生成的“SSH Key: My account SSH” 钥匙。 再次尝试git克隆项目。(使用sudo生成的密钥)

我得到了错误…

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

...当我的笔记本电脑因为Windows 10的错误更新而死机并被返回出厂设置后,我试图通过Git Bash提示与Bitbucket进行联系。我已经从备份中恢复了所有的ssh文件。

错误的原因原来是在电脑重建后,我的Windows帐户名不匹配。我了解到公钥文件id_rsa。pub以一个易于阅读的字符串结束,它包括我的Windows帐户名,后面跟着@符号,然后是计算机名。

当我最初设置我的电脑时,我创建了我的Windows帐户名,其中包括我的中间首字母,但当我的电脑重置为出厂设置时,我们新的DevOps人员创建了我的帐户名,其中没有我的中间首字母。

为了解决这个问题,我简单地编辑了我的公钥文件id_rsa。把我名字中间的首字母去掉了。我坚持使用相同的计算机名,所以没关系。我将文件内容复制到Windows剪贴板。然后我登录到Bitbucket,在我的头像下进入Bitbucket设置,并添加了一个新的公钥,在那里我粘贴了新的内容。

回到Git Bash提示,我通过输入命令确认它现在可以工作了…

ssh -T git@bitbucket.org

...然后我收到了我已经登录的消息

我在linux上也遇到了类似的问题。我通过登录到github服务器并创建一个部署密钥来解决这个问题。这是存储库的设置。然后,复制并粘贴我的公钥(通常在~/.ssh/id_rsa中)。Pub,但您的配置可能不同)。有一个复选框给予该密钥写权限。单击它(除非您只使用git进行部署,在这种情况下,不要单击它)。