解决git无法连接gitHub问题

解决git无法连接gitHub问题


事情的起因

我在使用git push我的项目时出现下面问题

fatal: unable to access ‘https://github.com/xxx.git/’: Recv failure: Connection was reset

或者

fatal: unable to access ‘https://github.com/xxx.git/’: Failed to connect to github.com port 443 after 21090 ms: Couldn’t connect to server

翻译过来就是无法连接到github

分析原因

  1. 检查网络

    无法连接一般是网络不行或者网络不稳定,使用浏览器访问github看看是否正常,如果浏览器无法访问或者加载的不是完整页面使用git可能就出现上面的问题


  2. 检查代理

    因为github访问比较慢,很多人都使用了代理,我也一样

    看一下自己是不是开了代理或者开过代理,为什么要讲开过呢?因为有些代理软件会修改系统配置参数一些问题

解决方法

  1. 浏览器无法访问github或者访问显示不全

    换一个好的能访问github的网络或者开代理


  2. 代理问题

    一般是开了代理能正常访问github但是使用git命令连接不上github

    给git设置代理可以解决

    以我为例,开了代理,可以浏览器可以正常访问github,代理的端口是10809

    查看git配置 git config --global -l

    > git config --global -l
    user.name=xxxx
    user.email=xxxx
    

    可以看到我的git是没设置代理的

    给git设置代理

    git config --global http.proxy 127.0.0.1:10809
    git config --global https.proxy 127.0.0.1:10809

    > git config --global http.proxy 127.0.0.1:10809
    > git config --global https.proxy 127.0.0.1:10809
    

    再次查看git配置 git config --global -l

    > git config --global -l
    user.name=xxx
    user.email=xxx
    http.proxy=127.0.0.1:10809
    https.proxy=127.0.0.1:10809
    

    使用git pull看看

    > git pull
    Already up to date.
    

    正常了

    还有一个问题是没开代理但是git设置了代理也会出现上面问题,解决方法是取消git代理

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

    > git config --global --unset http.proxy
    > git config --global --unset https.proxy
    > git config --global -l
    user.name=xxx
    user.email=xxx
    

猜你喜欢

转载自blog.csdn.net/yoyo_u/article/details/132637141
今日推荐