Skip to content

Instantly share code, notes, and snippets.

@chuyik

chuyik/README.md

Last active Oct 18, 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 HJianBo commented Jul 25, 2019

Works for me! Thanks

@ufan0

This comment has been minimized.

Copy link

@ufan0 ufan0 commented Jul 29, 2019

Thanks!

@wg415196363

This comment has been minimized.

Copy link

@wg415196363 wg415196363 commented Nov 9, 2019

👍

@SealinRepo

This comment has been minimized.

Copy link

@SealinRepo SealinRepo commented Jan 22, 2020

真棒🐂🍺

@banyudu

This comment has been minimized.

Copy link

@banyudu 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 laoshufeifei commented Feb 11, 2020

@banyudu 🐂🍺

@zyd

This comment has been minimized.

Copy link

@zyd 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 devin-wei commented Mar 4, 2020

works for me! 6666666

@bnshen

This comment has been minimized.

Copy link

@bnshen bnshen commented Mar 18, 2020

好用

@terry-xiaoyu

This comment has been minimized.

Copy link

@terry-xiaoyu terry-xiaoyu commented Mar 30, 2020

Have been looking for this for long time, thanks!

@SealinRepo

This comment has been minimized.

Copy link

@SealinRepo SealinRepo commented Apr 2, 2020

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

@samar1tan

This comment has been minimized.

Copy link

@samar1tan samar1tan commented Apr 3, 2020

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

+1

@Unalian

This comment has been minimized.

Copy link

@Unalian Unalian commented Apr 27, 2020

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

一样

@monsterhxw

This comment has been minimized.

Copy link

@monsterhxw monsterhxw commented May 15, 2020

thanks!

@yhwhu

This comment has been minimized.

Copy link

@yhwhu yhwhu commented May 30, 2020

thanks ! http

@youngcong

This comment has been minimized.

Copy link

@youngcong youngcong commented Jun 14, 2020

可真棒👍

@yinxianwei

This comment has been minimized.

Copy link

@yinxianwei yinxianwei commented Jul 14, 2020

thanks

@kallydev

This comment has been minimized.

Copy link

@kallydev kallydev commented Aug 2, 2020

thanks!

@bycgxss

This comment has been minimized.

Copy link

@bycgxss bycgxss commented Aug 10, 2020

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

俺也一样

@nomedia

This comment has been minimized.

Copy link

@nomedia nomedia commented Aug 28, 2020

works thanks

@Xib1uvXi

This comment has been minimized.

Copy link

@Xib1uvXi Xib1uvXi commented Sep 14, 2020

brew install socat 需要安装这个

@mixbe

This comment has been minimized.

Copy link

@mixbe mixbe commented Sep 15, 2020

mac works, thanks

@oldthreefeng

This comment has been minimized.

Copy link

@oldthreefeng oldthreefeng commented Sep 25, 2020

mac works, 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.