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文件。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值