1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > git pull 报错:权限不够 Permission denied (publickey)

git pull 报错:权限不够 Permission denied (publickey)

时间:2024-02-06 06:58:08

相关推荐

git pull 报错:权限不够  Permission denied (publickey)

一、背景

在git 提交的时候,突然就行不通,一直报错:

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

二、解决方案

1、刚开始以为是配置的原因,因此初始化git config

git config --list //查看当前的config配置git config --global user.name "youruser" //修改用户名git config --global user.email "你的邮箱" //修改为你的邮箱

这部分配置的是你个人的用户名称和电子邮件地址。这两条配置很重要,每次 Git 提交时都会引用这两条信息,说明是谁提交了更新,所以会随更新内容一起被永久纳入历史记录

关于git config,建议参考文档git config 文档

2、重新使用git pull 拉取数据,此时显示正常

三、git push 报错:

Access deniedexec request failed on channel 0fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.

1、先去看看.ssh有问题没

1、进入.ssh目录cd ~/.ssh2、查看此时下面的公钥私钥ls //看看有没有 id_rsa id_rsa_pub 等文件3、如果存在改文件,说明此时是配置好的。我们可以复制id_rsa_pub文件中的公钥,去码云上面,添加SSh公钥

如图所示从新添加个公钥试试。

2、继续git push

还是报错:

Access deniedexec request failed on channel 0fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.

这下ssh也没问题了,再报错,那是有八九还是配置的原因

1)进入git的配置文件所在

1、cd .git2、vim config

2)着重查看url部分

就是箭头指向这里,我这边是因为url的问题。和码云上克隆的地址不一样,所以才造成提交失败。

路径改为一致的路径。此时执行git push,发现执行成功。

总体来说,这部分的内容还是挺多的,排错过程试了很多方法。大家遇到错误也多找找原因,有可能就是很简单的问题,但是却浪费我们大量的时间。

end

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。