github 连接失败问题解决

Failed to connect to github.com port 443 after 21035 ms: Couldn’t connect to server解决办法

1. 通过代理(网上都这么说,可是我失败了)

网上都说什么通过代理解决这个问题。。。大概就是用下面的命令

git config --global http.proxy 127.0.0.1:59124

git config --global https.proxy 127.0.0.1:59124

注意后面的端口号要和本机开的代理一致,在这里 设置->网络和Internet->代理 查看端口

我使用以后报错:

Failed to connect to 127.0.0.1 port 59124 after 2030 ms: Couldn't connect to server

再次查找后,别人又说是因为我开了代理。。。。让我用如下命令取消代理:

git config --global --unset http.proxy

git config --global --unset https.proxy

回到原点。。。。

2. 使用SSH

折腾的没办法,就询问了gpt,它的回答是:

如果你正在使用HTTPS连接到GitHub,请尝试改用SSH。你可以使用以下命令将远程URL从HTTPS切换到SSH:

git remote set-url origin git@github.com:username/repository.git

尝试后,仍然报错:

ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

这个时候大概就是说ssh配置有问题,我重新走一遍这个配置,首先确保电脑安装了git,然后git鼠标右键应该可以看到git bash的命令,打开这个窗口,使用如下命令生成密钥:

ssh-keygen -t rsa -b 4096 -C "你的电子邮件地址"

它会让你做一些选项,不用管,无脑回车,会在C:\Users\user下生成一个.ssh文件夹,里面会有两个文件,可以使用notepad打开.pub文件,把里面的东西复制一下,粘贴到github中你的账户里,做法是:

  • 点击settings > SSH and GPG keys > New SSH key

把复制好的公钥粘贴上去添加即可,然后后续再做push pull等操作应该就能成功了

  • 17
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值