GitHub又打不开了怎么办?git pull push失败怎么办?
最近GitHub访问越来越不稳定,经常提示无法访问此网站。
一个解决办法是使用 https://github.com/521xueweihan/GitHub520
这个项目提供的hosts文件,内容会定时更新,Windows 系统保存在文件C:\Windows\System32\drivers\etc\hosts
推荐https://github.com/oldj/SwitchHosts 这个工具管理hosts。
访问GitHub解决后再说git pull和Git push失败的问题。
Connection reset by 20.205.243.160 port 22
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
可能在出口屏蔽了22端口,github允许你使用443端口进行ssh连接,因为443端口是访问https网站所必须的。
首先生成指定名字的密钥, ssh-keygen -t rsa -C "邮箱地址" -f ~/.ssh/github_sushengbuhuo 会生成 github_sushengbuhuo 和 github_sushengbuhuo.pub 这两个文件。
打开公钥文件~/.ssh/github_sushengbuhuo.pub ,并把内容复制至代码托管平台上 https://github.com/settings/keys ,添加成功。
修改config文件 vim ~/.ssh/config ,如果没有创建 config,这里7890是代理端口。
Host sushengbuhuo.github.com
Hostname ssh.github.com
Port 443
User git
ProxyCommand connect -H 127.0.0.1:7890 %h %p
IdentityFile ~/.ssh/github_sushengbuhuo
测试下连接成功 ssh -T git@github.com
Hi sushengbuhuo! You've successfully authenticated, but GitHub does not provide shell access.
然后使用ssh拉取代码
git clone git@github.com:521xueweihan/GitHub520.git
github 上选择clone地址时,选择ssh地址, 这样git push 与 git clone 都可以直接走代理了,不需要输入密码。
这里使用的命令行工具是git bash。
这里顺便推荐个油猴脚本https://github.com/XIU2/UserScript
方便下载GitHub文件。