Git代理配置
本机 v2rayN 开的服务,默认 http 端口为 10809,socks端口为10808
# 接管配置
# 全部接管
git config --global http.proxy socks5://127.0.0.1:端口号
git config --global https.proxy socks5://127.0.0.1:端口号
#比如端口号为10808,执行下面的命令即可
# git config --global http.proxy socks5://127.0.0.1:10808
# git config --global https.proxy socks5://127.0.0.1:10808
1
2
3
4
5
2
3
4
5
# 接管 Github
git config --global http.https://github.com.proxy socks5://127.0.0.1:端口号
git config --global https.https://github.com.proxy socks5://127.0.0.1:端口号
#git config --global http.https://github.com.proxy socks5://127.0.0.1:10808
#git config --global https.https://github.com.proxy socks5://127.0.0.1:10808
1
2
3
4
2
3
4
# 检查设置
# 全部接管的检查
git config --global --get http.proxy
git config --global --get https.proxy
1
2
2
# 接管 Github 的检查
git config --global --get http.https://github.com.proxy
git config --global --get https.https://github.com.proxy
1
2
2
# 还原设置
# 取消全部接管
git config --global --unset http.proxy
git config --global --unset https.proxy
1
2
2
# 取消接管 Github
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy
1
2
2
# SSH代理
修改 ~/.ssh/config
文件(不存在则新建):
~
就是%userprofile%
,也就是用户目录
# 端口号要替换
ProxyCommand connect -S 127.0.0.1:10808 -a none %h %p
Host github.com
User git
Port 22
Hostname github.com
# 注意修改路径为你的路径
IdentityFile "C:\Users\Administrator.SC-201902031211\.ssh\id_rsa"
TCPKeepAlive yes
Host ssh.github.com
User git
Port 443
Hostname ssh.github.com
# 注意修改路径为你的路径
IdentityFile "C:\Users\Administrator.SC-201902031211\.ssh\id_rsa"
TCPKeepAlive yes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 测试
最后下载一个文件测试一下
未配置前,下载了好久都下载不下来
配置后
这个文件大小总共3G
# 参考文章
编辑 (opens new window)
上次更新: 2024/12/19, 09:15:30