配置 git 代理
配置 git 的 http https 代理
Linux 和 Windows 都适用
1# gitlab 服务器在国外下载速度速度收到很大影响。下面对 gitlab 配置 http https 代理。同理也可以对 github 配置 http https 代理。 2git config --global http.https://gitlab.com.proxy socks5://127.0.0.1:1080 3git config --global http.https://github.com.proxy socks5://127.0.0.1:1080 4 5# 其中 socks5://127.0.0.1:1080 换成你使用代理服务。如: 6git config --global http.https://gitlab.com.proxy http://127.0.0.1:8080 7
配置 git 的 ssh 代理
Linux 系统
1# 需要安装 openbsd-netcat 来实现转发,以 Manjaro Linux 安装为例: 2sudo pacman -S openbsd-netcat 3 4 5# 在用户目录下的 .ssh/ 创建 config 文件 6vim ~/.ssh/config 7# 详细配置如下 8 9 10Host github.com 11Host gitlab.com 12ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p 13HostName %h 14Port 22 15User git 16IdentityFile ~/.ssh/id_rsa 17IdentitiesOnly yes
Windows 系统
Windows 10 带有 connect 转发工具无需手动安装。同样也是在 在用户目录下(c:\User\username\.ssh\)的 .ssh\ 创建 config 文件
1Host github.com 2Host gitlab.com 3ProxyCommand connect -S 127.0.0.1:1080 %h %p # -H 为 HTTP 4HostName %h 5Port 22 6User git 7IdentityFile ~/.ssh/id_rsa 8IdentitiesOnly yes