git ssh: connect to host github.com port 22: Connection refused

 

今天,在公司同步github代码到本地的时候,爆出了这样的一个错误ssh: connect to host github.com port 22: Connection refused。根据英文可以看出,ssh端口号被拒绝了。问了下 端口被运维给禁了。

git远程仓库通常有两种协议 

ssh被禁了 那就切换成http

第一步,查看当前git的远程仓库版本

$ git remote -v

git ssh: connect to host github.com port 22: Connection refused

第二步 移除掉远程仓库的配置

$ git remote rm origin

git ssh: connect to host github.com port 22: Connection refused

第三步 添加对应项目的http形式

git remote add origin https://.......

git ssh: connect to host github.com port 22: Connection refused

第四步 继续查看远程仓库版本

$ git remote -v

git ssh: connect to host github.com port 22: Connection refused 

第五步 尝试拉取

$ git pull origin 对应分支

git ssh: connect to host github.com port 22: Connection refused