如何给 SourceTree 访问 Github 时设置代理?

作者: 王炳明 分类: 工具库 发布时间: 2021-03-20 10:01 热度:8,734

最近 github 访问是越来越慢了,连续 pull push 都超时失败。

就打算给 SourceTree 设置一下代理。

1. Windows 平台

Windows版的 SourceTree 在 工具 -> 选项 -> 网络 下,选择自定义代理,输入你的代理信息。

比如我使用的是 socks5://127.0.0.1:1080,一定要注意协议(如 http,https,sock5)一定不能省略。

点击确定保存,就可以使用代理了
如何给 SourceTree 访问 Github 时设置代理?

2. MacOS 平台

搜索了下,mac 版的 SourceTree 并没有设置代理的配置,因此要想走代理,可以直接从 Git 的配置下手,设置全局的代理。

2.1 移除当前 Git 全局配置代理

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

2.2 查看信息 Git 配置信息

git config --global -l

2.3 重新为 Git 设置代理

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

2.4 再次查看 gitconfig 的配置

使用如下命令再次查看配置文件

cat ~/.gitconfig

会发现多出了这两行

[http]
    proxy = socks5://127.0.0.1:1080
[https]
    proxy = socks5://127.0.0.1:1080

文章有帮助,请作者喝杯咖啡?

发表评论