为Github Desktop 设置代理

Posted by     "DD" on Monday, May 22, 2023 | 阅读 |,阅读约 1 分钟

我们在使用Github Desktop时,经常由于不可说的原因在同步代码时会报提示:

fatal: unable to access 'https://github.com/username/reprository.git/': Failed to connect to github.com port 443: Timed out

当然我们可以将自己的代理服务设置成系统代理,来解决这个问题,但其实往往并不希望这样做。

Github Desktop的设置并没有设置代理的地方,那么该怎么办呢?

Github Desktop是基于git的客户端,所以我们只需要对git配置进行修改就可以了。 理论上要这样做: 找到 .gitconfig 配置文件,在文件结尾添加:

[http]
proxy = http://www.proxy.com:port

.gitconfig文件在不同的系统中位于不同的路径下:

Windows的路径: %HOMEPATH%/.gitconfig

Mac / Linux的路径: ~/.gitconfig

修改.gitconfig, 在其末尾追加以下内容:


[http]
proxy = socks5://127.0.0.1:1088
[https]
proxy = socks5://127.0.0.1:1088
[git]
proxy = socks5://127.0.0.1:1088

127.0.0.1:1088 代理服务地址根据实际设置

此配置方法相当于执行了以下命令,故而设置后对命令行也有效果:

git config --global http.proxy socks5://127.0.0.1:1088
git config --global https.proxy socks5://127.0.0.1:1088
git config --global git.proxy socks5://127.0.0.1:1088

参考文章

  1. https://exp-blog.com/scm/githubdesktop-dai-li-she-zhi/
  2. https://kassadin.moe/2019/07/17/003-how-to-set-proxy-for-Github-desktop/
  3. https://blog.csdn.net/fhqfghgdx1993/article/details/80205585

本作品由 IvyWooo 采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可,转载请注明出处。

本文链接

「真诚赞赏,手留余香」

猫猫和狗狗的小窝

真诚赞赏,手留余香

使用微信扫描二维码完成支付


本文总阅读量