300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > git报错 ssh: Could not resolve hostname gitee.com:xxxxxx: Name or service not known fatal

git报错 ssh: Could not resolve hostname gitee.com:xxxxxx: Name or service not known fatal

时间:2020-09-19 03:58:03

相关推荐

git报错 ssh: Could not resolve hostname gitee.com:xxxxxx: Name or service not known fatal

问题

使用git进行push操作时突然出问题,报错如下:

ssh: Could not resolve hostname git: xxxxx: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.

查了大半天,有的说重新配置ssh公钥,重新配置了好几遍,都没用,问题依旧。

有的说在/etc/hosts文件中添加配置ip,因为hosts文件不太好修改,要管理员权限,好不容易修改成功了,还是没用( o(╥﹏╥)o ,网上很多这个解决方案的,真坑 )。

百度了大半天最终决定去谷歌试试,终于在谷歌搜索到一个解决方案:

Change the[remote "origin"]urlvalue in.gitconfigor.config/git/configfile

Previously:

https://git@:userName/repo.git

OR

ssh://git@:userName/repo.git

New:

git@:userName/repo.git

(原文:/questions/53129706/ssh-could-not-resolve-hostname-git-name-or-service-not-known-fatal-could-not)

解决方案

就是修改.git下的config文件,将[remote "origin"]下的url从原来的

https://git@:userName/repo.git 或 ssh://git@:userName/repo.git

修改为:

git@:userName/repo.git

我原来是:/xxxx/xxxxx.git

修改后如下:

问题最终解决!

问题分析

之所以会出现这样的问题,应该是本来没有配置ssh公钥,后面配置了,

origin数据源原来是https的,需要换成ssh的才行。

附git数据源的三种修改方式:

方式1. 修改命令

git remte origin set-url URL

方式2. 先删后加

删除命令:git remote rm origin

添加命令:git remote add origin git@:Liutos/foobar.git

方式3. 直接修改config文件

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