Golang——安装git工具失败,Failed to connect to github.com port 443 after 21078 ms: Couldn't connect to server

  1. go env -w GO111MODULE=on
  2. go env -w GOPROXY=https://goproxy.cn,direct
  3. 注意: 重启vscode后 即可安装

Golang——Failed to connect to github.com port 443:Timed out

解决方案:
1、首先使用浏览器确认包是否可正常访问到 2、查看当前git是否设置了其他代理或指定的地址,由于该仓库地址下没有导致。
<code>-- 查看是否设置
 git config --global http.proxy
-- 去除相关设置
 git config --global --unset http.proxy
</code>
3、拉取再试尝试,如果仍不成功,可再设置git config --global url.git@github.com:.insteadOf https://github.com/使其地址都走https尝试。
  要将 git 配置中的 url.git 值恢复为默认设置,可以使用以下命令行操作: (git config --global --unset-all url.git
4、仍然失败,则设置hosts文件进行再次尝试。

 

设置Socks5代理

git config --global http.proxy 'socks5://127.0.0.1:1080' && git config --global https.proxy 'socks5://127.0.0.1:1080'

设置http/https代理

git config --global https.proxy http://127.0.0.1:1080 && git config --global https.proxy https://127.0.0.1:1080

取消代理

git config --global --unset http.proxy && git config --global --unset https.proxy

强制转换协议以使用代理

git config --global url."https://github".insteadOf git://github
git config --global url."git@github.com:".insteadOf "https://github.com/"
git config --global url.ssh://git@bitbucket.org/.insteadOf https://bitbucket.org/

 

原因
新设备还不存在ssh key或者ssh key失效,解决办法就是新建一个ssh key。

步骤
1、查看shh key是否存在(若存在,直接跳到步骤3)

ls ~/.ssh/
2、新建ssh key (配置项默认回车)

ssh-keygen -t rsa -C "GitHub用户名"
一直回车,出现如下提示,新建成功
3.eval "$(ssh-agent -s)"

4.ssh-add ~/.ssh/id_rsa

登录:https://github.com/settings/keys

https://github.com/settings/ssh/new

C:\Users/Admin/.ssh/id_rsa.pub

 

 

重新git clone,就可以啦

 

posted @ 2024-01-06 23:33  也许明天  阅读(114)  评论(0编辑  收藏  举报