Git 提交更改时遇到网络问题会报错,求解决办法

描述

我在本地有很多个项目,Visual Studio Code本地编辑代码上传,但是一到上传的时候就总是报错!不过是时好时坏。

事例图片

Git 报错

这是我找到的其中一些报错:
01.
image

(1)


(2)

> git pull --tags origin main
fatal: unable to access 'https://github.com/LXJGZS/ltmt.git/': gnutls_handshake() failed: The TLS connection was non-properly terminated.

Ping Github 终端输出

~$ ping github.com
PING github.com (140.82.112.3) 56(84) bytes of data.
64 bytes from gist.github.com (140.82.112.3): icmp_seq=1 ttl=47 time=238 ms
64 bytes from gist.github.com (140.82.112.3): icmp_seq=2 ttl=47 time=238 ms
64 bytes from gist.github.com (140.82.112.3): icmp_seq=3 ttl=47 time=246 ms
64 bytes from gist.github.com (140.82.112.3): icmp_seq=4 ttl=47 time=246 ms
--- github.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 5ms
rtt min/avg/max/mdev = 238.087/242.208/246.362/3.997 ms

本人Hosts文件

127.0.0.1	localhost

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
# Generated by hosts-generator start

185.199.109.154   github.githubassets.com
140.82.113.21     central.github.com
185.199.108.133   desktop.githubusercontent.com
185.199.108.153   assets-cdn.github.com
185.199.110.133   camo.githubusercontent.com
185.199.108.133   github.map.fastly.net
146.75.93.194     github.global.ssl.fastly.net
140.82.112.3      gist.github.com
185.199.109.153   github.io
140.82.112.3      github.com
140.82.114.5      api.github.com
185.199.108.133   raw.githubusercontent.com
185.199.111.133   user-images.githubusercontent.com
185.199.110.133   favicons.githubusercontent.com
185.199.108.133   avatars5.githubusercontent.com
185.199.109.133   avatars4.githubusercontent.com
185.199.108.133   avatars3.githubusercontent.com
185.199.108.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.113.9      codeload.github.com
52.216.53.9       github-cloud.s3.amazonaws.com
3.5.29.42         github-com.s3.amazonaws.com
52.217.228.57     github-production-release-asset-2e65be.s3.amazonaws.com
52.217.119.9      github-production-user-asset-6210df.s3.amazonaws.com
3.5.25.30         github-production-repository-file-5c1aeb.s3.amazonaws.com
185.199.109.153   githubstatus.com
140.82.113.18     github.community
185.199.108.133   media.githubusercontent.com

# 8/21/2024, 4:24:40 PM
#  https://github.com/fliu2476/gh-hosts.git
# Generated by hosts-generator end

最后求各位佬帮忙吧。

3 个赞

说报错,报什么错呢?

1 个赞

噢,找错了,我再看看

找好了

这不是网络问题吗,和vscode的git有啥关系呢

2 个赞

github 连接超时,时好时坏,这不是国内的正常现象吗。 ::

1 个赞

对呀,这不是网络问题吗

1 个赞
[http]
	sslverify = false
	proxy = 127.0.0.1:xxxx
[https]
	proxy = 127.0.0.1:xxxx

在 .gitconfig 中配置即可,xxxx是本地代理设置的端口

1 个赞
C:\Users\username\.gitconfig

我这是Linux

~/.gitconfig

找到了,xxxx随便填数字?

你没梯子么,梯子的端口号

我去看看tz

那你去 https://linux.do/c/trade/10 找个免费的梯子

我之前也遇到过连接报错,问的gpt让远程仓库地址改成ssh形式,好像就好了。好久没用过了都忘了。

不要用 http 的链接

tz的端口在这里看:

代理的端口设置成这个端口就可以了