即使我使用了科学上网,但push上github还是不科学

于是查找资料有了以下两种方法

方法一:修改hosts文件

首先打开文件夹

C:\Windows\System32\drivers\etc 下的host文件 ( 使用记事本或者编译器打开都可以 )

在下面增加并保存如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
185.199.108.154   github.githubassets.com
140.82.113.22 central.github.com
185.199.108.133 desktop.githubusercontent.com
185.199.109.153 assets-cdn.github.com
185.199.110.133 camo.githubusercontent.com
185.199.108.133 github.map.fastly.net
151.101.201.194 github.global.ssl.fastly.net
140.82.116.3 gist.github.com
185.199.108.153 github.io
140.82.116.3 github.com
140.82.116.6 api.github.com
185.199.111.133 raw.githubusercontent.com
185.199.108.133 user-images.githubusercontent.com
185.199.108.133 favicons.githubusercontent.com
185.199.110.133 avatars5.githubusercontent.com
185.199.108.133 avatars4.githubusercontent.com
185.199.108.133 avatars3.githubusercontent.com
185.199.109.133 avatars2.githubusercontent.com
185.199.108.133 avatars1.githubusercontent.com
185.199.108.133 avatars0.githubusercontent.com
185.199.109.133 avatars.githubusercontent.com
140.82.116.9 codeload.github.com
52.217.135.153 github-cloud.s3.amazonaws.com
3.5.21.109 github-com.s3.amazonaws.com
3.5.29.177 github-production-release-asset-2e65be.s3.amazonaws.com
52.216.63.25 github-production-user-asset-6210df.s3.amazonaws.com
52.217.223.1 github-production-repository-file-5c1aeb.s3.amazonaws.com
185.199.110.153 githubstatus.com
140.82.112.17 github.community
185.199.108.133 media.githubusercontent.com

重新push,问题解决——

方法二:修改代理

首先打开网络设置

打开代理

记住你的ip和代理

修改 Git 的网络设置

1
2
3
# 注意修改成自己的IP和端口号
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

⚠️:如果后续遇到OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443

可以尝试更换代理协议为 http 协议,运行如下代码:

1
2
git config --global http.https://github.com.proxy http://127.0.0.1:7890
git config --global https.https://github.com.proxy https://127.0.0.1:7890

后续过一段时间如果遇到443,就重新设置一下。