git unable to access 'xxx': Recv failure: Connection reset by peer

git clone 仓库时报错,unable to access 'xxx': Recv failure: Connection reset by peer

之前使用https克隆的仓库,pull、push都没问题,今天突然报错了。查询一番后,将https形式改为ssh形式,亲测可以解决。

设置ssh

  1. 本地获取 id_rsa.pub
ssh-keygen -t rsa -b 4096 -C "你的github邮箱"

接下来一路回车,然后查看生成的文件

cd .ssh 
cat id_rsa.pub
  1. github设置ssh key

1391690743244_.pic.jpg

现在你在电脑上面clone仓库就不会报错了。

原有项目

如果是之前在电脑上已经克隆下的项目,需要将修改一下远程地址。

  1. 查看远程地址
git remote -v 
  1. 修改远程地址
git remote set-url origin git@github.com:xxx/xxx.git
  1. 查看远程地址
git remote -v 

然后就可以正常push 、 pull 了。