Git 针对 GitLab Github 配置 HTTP HTTPS SSH 代理

14 篇文章 0 订阅
13 篇文章 0 订阅

配置 git 代理

配置 git 的 http https 代理

Linux 和 Windows 都适用

# gitlab 服务器在国外下载速度速度收到很大影响。下面对 gitlab 配置 http https 代理。同理也可以对 github 配置 http https 代理。
git config --global http.https://gitlab.com.proxy socks5://127.0.0.1:1080
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

# 其中 socks5://127.0.0.1:1080 换成你使用代理服务。如:
git config --global http.https://gitlab.com.proxy http://127.0.0.1:8080

配置 git 的 ssh 代理

Linux 系统

# 需要安装 openbsd-netcat 来实现转发,以 Manjaro Linux 安装为例:
sudo pacman -S openbsd-netcat
# 在用户目录下的 .ssh/ 创建 config 文件
vim ~/.ssh/config
# 详细配置如下
Host github.com
Host gitlab.com
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
HostName %h
Port 22
User git
IdentityFile  ~/.ssh/id_rsa
IdentitiesOnly yes

Windows 系统

Windows 10 带有 connect 转发工具无需手动安装。同样也是在 在用户目录下(c:\User\username\.ssh\)的 .ssh\ 创建 config 文件

Host github.com
Host gitlab.com
ProxyCommand connect -S 127.0.0.1:1080 %h %p # -H 为 HTTP
HostName %h
Port 22
User git
IdentityFile  ~/.ssh/id_rsa
IdentitiesOnly yes
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值