解决IDEA无法克隆GitHub上的工程的问题

发布于:2025-08-02 ⋅ 阅读:(11) ⋅ 点赞:(0)

背景:

        内网机器,需要代理才能访问GitHub

        IDEA上的proxy设置已配置

问题回顾:

        我要在本地调试zookeeper的源码,所以想通过IDEA自带的Git功能,直接把zk的代码拉下来。但是测试了几次都失败了,然后切换到Git工具栏,查看Console的日志,报错如下:

14:41:15.324: [zookeeper] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false fetch origin --recurse-submodules=no --progress --prune
fatal: unable to access 'https://github.com/apache/zookeeper.git/': Failed to connect to github.com port 443 after 21099 ms: Couldn't connect to server

日志表示访问无法访问github,但检查了IDEA的proxy设置,也通过界面上的Check Connection测试了链接可访问。如下图:

        奇了怪了,代理也有,github的账号我在IDEA上也登录成功了,照理说不应该报错啊。回头再去看上面的日志,发现是用的git命令访问的,既然如此,那就用git命令在命令提示行里面去试试,看看得到的效果是不是一样的。执行结果如下:

C:\Users\test>git clone https://github.com/apache/zookeeper.git
Cloning into 'zookeeper'...
fatal: unable to access 'https://github.com/apache/zookeeper.git/': Failed to connect to github.com port 443 after 21214 ms: Couldn't connect to server

这个结果和通过IDEA访问的结果是一样的,说明IDEA的proxy对git命令并没有效果。问题找到了,那就好办了,先通过如下命令,查询一下git是否已经设置了代理:

C:\Users\test>git config --global --get http.proxy

C:\Users\test>git config --global --get https.proxy

 结果表示没有设置代理,那就重新对git设置代理,设置如下:

C:\Users\test>git config --global http.proxy http://10.10.10.10:8000

C:\Users\test>git config --global https.proxy http://10.10.10.10:8000

然后再查询一下是否设置成功:

C:\Users\test>git config --global --get http.proxy
http://10.10.10.10:8000


C:\Users\test>git config --global --get https.proxy
http://10.10.10.10:8000

设置成功,回到IDEA重新clone zk的代码,成功了。


网站公告

今日签到

点亮在社区的每一天
去签到