Skip to content

Instantly share code, notes, and snippets.

@bluethon
Created January 18, 2017 08:25
Show Gist options
  • Save bluethon/45766d0a4541ab633e32a49b6c4e4bdd to your computer and use it in GitHub Desktop.
Save bluethon/45766d0a4541ab633e32a49b6c4e4bdd to your computer and use it in GitHub Desktop.
设置git使用socks5代理
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
@hikerwu
Copy link

hikerwu commented Jun 22, 2020

如果有问题,可以尝试看看/etc/hosts里面,如果配置了hosts,可以去掉,再加上上面的配置,看看效果。

@rikonaka
Copy link

SadPencil说得对,第一行就可以了,还有我试了socks5h没反应😂

@gethurb
Copy link

gethurb commented Oct 28, 2020

效果拔群,从20kb变成2mb

@Whikiey
Copy link

Whikiey commented Aug 7, 2021

不需要单引号

@tombarbar
Copy link

这都啥啊 没反应

@Codennnn
Copy link

如果只想对 GitHub 进行代理,则可以这么做:

# 以代理端口 7890 为例
git config --global http.https://github.com.proxy socks5h://127.0.0.1:7890

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

@AroundKiki
Copy link

我实际的经验是,如果git远程仓库是通过ssh连接的,换成https连接才可以走代理。因为ssh不走代理,那么他解析不了dns的情况下就报错了。

@Ansen
Copy link

Ansen commented Jul 7, 2024

我实际的经验是,如果git远程仓库是通过ssh连接的,换成https连接才可以走代理。因为ssh不走代理,那么他解析不了dns的情况下就报错了。

为 ssh 配置代理就好了

# cat .ssh/config 
Host xxxx
# socks5 proxy
#    ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
# http proxy
#    ProxyCommand nc -X connect -x 127.0.0.1:1081 %h %p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment