git添加远程库的时候出现的错误总结

1.GIT报错:connect to host github.com port 22: Connection timed out

错误.png

刚开始以为是密钥错了,尝试把.ssh文件重新生成替换了无数遍,还是不行。

后来通过
1.在.ssh文件夹下新建一个config文件,并写入如下代码:

Host github.com
User "xxx@qq.com"       //你的账户邮箱
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa 
Port 443

2.或者在git的安装路径的ssh文件中添加1中代码(第一种方法不行就用第二种方法)


错误.png

修改示例如下图:


错误.png

然后再执行命令:

$ ssh -T git@github.com                 //只用敲这一行
Hi Anbrosex! You've successfully authenticated, but GitHub does not provide shell access.

问题解决。



2.GIT报错: Repository not found.

报错代码:


$ git push -u origin master
ERROR: Repository not found.
fatal: Could not read from remote repository.

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

解决方案:

1.git remote set-url命令修改remote URL

2.git remote set-url传递两个参数

remote name。例如,origin或者upstream

new remote url。例如,git@github.com:USERNAME/OTHERREPOSITORY.git



例如先执行代码:

git remote set-url origin git@github.com:xxxxxx/xxxxxx.git

再执行代码:

$ git remote -v                 //只用敲这一行
origin  git@github.com:Anbrosex/image.git (fetch)
origin  git@github.com:Anbrosex/image.git (push)

问题解决。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容