使用 git push 推送代码时,遇到如下错误:
$ git push -u origin master
kex_exchange_identification: Connection closed by remote host
Connection closed by 39.152.16.167 port 22
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
产生这个错误一般都是网络问题,比如临时网络波动或者使用了代理上网,比如VPN之类的。等一会网络恢复或关闭代理后重新推送即可。
如果网络一直有问题或关闭代理后仍然无法推送,那么可以将 SSH 方式切换成 HTTPS 方式。
将 SSH 改为 HTTPS 格式的远程库:
git remote set-url origin https://github.com/www_02405_com/xxx.git
这样就可以正常推送了。