Skip to content

Instantly share code, notes, and snippets.

@chuyik chuyik/README.md
Last active Jul 14, 2020

Embed
What would you like to do?
macOS 给 Git(Github) 设置代理(HTTP/SSH)

分辨需要设置的代理

一、HTTP 形式

走 HTTP 代理

git config --global http.proxy "http://127.0.0.1:8080"
git config --global https.proxy "http://127.0.0.1:8080"

走 socks5 代理(如 Shadowsocks)

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

取消设置

git config --global --unset http.proxy
git config --global --unset https.proxy

二、SSH 形式

修改 ~/.ssh/config 文件(不存在则新建):

# 必须是 github.com
Host github.com
   HostName github.com
   User git
   # 走 HTTP 代理
   # ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=8080
   # 走 socks5 代理(如 Shadowsocks)
   # ProxyCommand nc -v -x 127.0.0.1:1080 %h %p
@HJianBo

This comment has been minimized.

Copy link

HJianBo commented Jul 25, 2019

Works for me! Thanks

@ufan0

This comment has been minimized.

Copy link

ufan0 commented Jul 29, 2019

Thanks!

@wg415196363

This comment has been minimized.

Copy link

wg415196363 commented Nov 9, 2019

👍

@SealinRepo

This comment has been minimized.

Copy link

SealinRepo commented Jan 22, 2020

真棒🐂🍺

@banyudu

This comment has been minimized.

Copy link

banyudu commented Feb 10, 2020

对于Windows用户,要使用socks5代理却没有 nc 的,可以将
ProxyCommand nc -v -x 127.0.0.1:1080 %h %p
换成
ProxyCommand connect -S 127.0.0.1:1080 %h %p

@laoshufeifei

This comment has been minimized.

Copy link

laoshufeifei commented Feb 11, 2020

@banyudu 🐂🍺

@zyd

This comment has been minimized.

Copy link

zyd commented Feb 13, 2020

对于Windows用户,要使用socks5代理却没有 nc 的,可以将
ProxyCommand nc -v -x 127.0.0.1:1080 %h %p
换成
ProxyCommand connect -S 127.0.0.1:1080 %h %p

亲测好用👍

@devin-wei

This comment has been minimized.

Copy link

devin-wei commented Mar 4, 2020

works for me! 6666666

@bnshen

This comment has been minimized.

Copy link

bnshen commented Mar 18, 2020

好用

@terry-xiaoyu

This comment has been minimized.

Copy link

terry-xiaoyu commented Mar 30, 2020

Have been looking for this for long time, thanks!

@SealinRepo

This comment has been minimized.

Copy link

SealinRepo commented Apr 2, 2020

SSH方式加了代理配置后github验证失败了, 关掉这个配置是可以正常使用github的,有人遇到过吗?

@samar1tan

This comment has been minimized.

Copy link

samar1tan commented Apr 3, 2020

SSH方式加了代理配置后github验证失败了, 关掉这个配置是可以正常使用github的,有人遇到过吗?

+1

@Unalian

This comment has been minimized.

Copy link

Unalian commented Apr 27, 2020

SSH方式加了代理配置后github验证失败了, 关掉这个配置是可以正常使用github的,有人遇到过吗?

一样

@monsterhxw

This comment has been minimized.

Copy link

monsterhxw commented May 15, 2020

thanks!

@yhwhu

This comment has been minimized.

Copy link

yhwhu commented May 30, 2020

thanks ! http

@youngcong

This comment has been minimized.

Copy link

youngcong commented Jun 14, 2020

可真棒👍

@yinxianwei

This comment has been minimized.

Copy link

yinxianwei commented Jul 14, 2020

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.