Git报错:Could not read from remote repository.

warning: 这篇文章距离上次修改已过1552天,其中的内容可能已经有所变动。

今天新建一个Git仓,远程提交的时候报 Could not read from remote repository. 错误。

具体报错如下:

$ git push -u origin master
ssh: Could not resolve hostname nas-pc192.168.199.102: Name or service not known
fatal: Could not read from remote repository.

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

2020-01-18_183224.png2020-01-18_183224.png


感觉可能是密钥出现问题。毕竟好久没用了。(这是个备份仓)

检查发现没有问题。(另一个项目提交没有问题)

2020-01-18_182636.png2020-01-18_182636.png


尝试添加密钥到这个仓库(仍然报错)

#若执行 ssh-add 报:Could not open a connection to your authentication agent. 错误,则先此命令(见下图)
ssh-agent bash

#添加密钥
ssh-add ~/.ssh/id_rsa

尝试添加密钥后仍报错尝试添加密钥后仍报错


观察发现,远程仓库地址不一致,怀疑问题出在这里。

仓库报错仓库报错

实际仓库地址实际仓库地址


重新添加地址,用单引号包裹,ok问题解决。

2020-01-18_183853.png2020-01-18_183853.png

远程仓库添加成功远程仓库添加成功


info:反思:这次问题可能是,命令行把 NAS-PC$@ 中的 $@ 识别为变量,导致地址错误。下次添加时候要用单引号包裹。
评论已关闭