我无法克隆一个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

并且存储库存在。


当前回答

我在windows命令行运行git clone命令时遇到了同样的问题。但是该命令在Git Bash中成功运行。

其他回答

我看到这个错误信息有很多不同的原因。 当我试图在本地设置另一个存储库时,除了一个已经完全使用ssh等,并将其连接到同一服务器,但其他存储库时,我也犯了同样的错误。这里找不到答案,但我想出来了。所以我发布了它。希望能帮到别人。

git remote add origin git@git.ourserver.com:teamalpha/repositorytwo.git

我得到了错误…

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

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

如果这些答案都没用

你使用的是Windows 您可以使用Putty生成密钥,或者已经安装了Putty 你的电脑 你可以用CMD或PowerShell生成密钥

Try

删除你的钥匙 在windows上搜索Git Bash,然后生成一个 Git Bash命令行中的新密钥 添加公钥到您的在线回购

然后,你会发现git克隆后,输入yes确认,它应该开始克隆

在更改我克隆的文件夹的权限后,它工作了:

sudo chown -R ubuntu:ubuntu /var/projects

如果在创建SSH并将其添加到您的Bitbucket帐户或其他地方后仍然存在访问问题,您需要在git, OSX或Linux上的终端上执行以下操作:

# Lists already added identities (‘ssh keys’)
ssh-add -l

然后,如果你没有看到你的密钥列出,添加它与以下(替换身份为其真实名称):

# Add a new identity
ssh-add ~/.ssh/identity

这对我很管用。