1. 程式人生 > >Git 設定和取消代理

Git 設定和取消代理

參考: https://gist.github.com/laispace/666dd7b27e9116faece6

前提是你本地有 socks5 代理。

上面參考地址作者提供的配置無效,但是後面回覆中的配置有效:

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

還有針對 github.com 的單獨配置:

#只對github.com
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

#取消代理
git config --global --unset http.https://github.com.proxy)

直接使用 socks5 的速度很快,近百兆的專案能在短時間內下載完。

測試:

$ git clone https://github.com/abel533/mybatis-3.git
Cloning into 'mybatis-3'...
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 209581 (delta 0), reused 12 (delta 0), pack-reused 209561
Receiving objects: 100% (209581/209581), 72.32 MiB | 405.00 KiB/s, done.
Resolving deltas: 100% (176933/176933), done.

速度在 405.00 KiB/s,已經很快了。

曾經為此寫過的一個小應用可以關閉了。
在這裡插入圖片描述