Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@h2so

This comment has been minimized.

Show comment Hide comment
@h2so

h2so Dec 20, 2015

git config --local https.proxy https://127.0.0.1:1080 我这样配置有什么问题么?为什么还是没走ss代理呢?

h2so commented Dec 20, 2015

git config --local https.proxy https://127.0.0.1:1080 我这样配置有什么问题么?为什么还是没走ss代理呢?

@itolfh

This comment has been minimized.

Show comment Hide comment
@itolfh

itolfh Jan 13, 2016

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

itolfh commented Jan 13, 2016

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

@chunxiao369

This comment has been minimized.

Show comment Hide comment
@chunxiao369

chunxiao369 May 8, 2016

Thanks!

Thanks!

@zhuyingda

This comment has been minimized.

Show comment Hide comment
@zhuyingda

zhuyingda Sep 28, 2016

请问一下,我只设置了git config --global https 而没设置git config --global http的时候,clone一个google的git仓库依然不行,后来加上了http的设置才可以,我也是ss代理 端口都和你们一样,有人知道这是为什么吗? 我的clone仓库url是https的啊,但还是需要把http和https代理都挂上才可以吗?

请问一下,我只设置了git config --global https 而没设置git config --global http的时候,clone一个google的git仓库依然不行,后来加上了http的设置才可以,我也是ss代理 端口都和你们一样,有人知道这是为什么吗? 我的clone仓库url是https的啊,但还是需要把http和https代理都挂上才可以吗?

@tolbkni

This comment has been minimized.

Show comment Hide comment
@tolbkni

tolbkni Oct 26, 2016

@zhuyingda 显然是 https 不起作用,只有 http 起作用

tolbkni commented Oct 26, 2016

@zhuyingda 显然是 https 不起作用,只有 http 起作用

@joydragon-wang

This comment has been minimized.

Show comment Hide comment
@joydragon-wang

joydragon-wang Oct 31, 2016

It works. Thank you very much.

It works. Thank you very much.

@yeweishuai

This comment has been minimized.

Show comment Hide comment
@yeweishuai

yeweishuai Nov 6, 2016

My ubuntu server was blocked to git clone some github repo,

Do as @itolfh said,

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

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

my git works!
Thanks @itolfh

My ubuntu server was blocked to git clone some github repo,

Do as @itolfh said,

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

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

my git works!
Thanks @itolfh

@AStogov

This comment has been minimized.

Show comment Hide comment
@AStogov

AStogov Nov 7, 2016

thanks a lot

AStogov commented Nov 7, 2016

thanks a lot

@xuinvip

This comment has been minimized.

Show comment Hide comment
@xuinvip

xuinvip Dec 11, 2016

thanks!

xuinvip commented Dec 11, 2016

thanks!

@BobLiu20

This comment has been minimized.

Show comment Hide comment
@BobLiu20

BobLiu20 Jan 11, 2017

thanks! Working for me.

thanks! Working for me.

@iTofu

This comment has been minimized.

Show comment Hide comment
@iTofu

iTofu Jan 13, 2017

Thank you! It works for me.

iTofu commented Jan 13, 2017

Thank you! It works for me.

@iqiancheng

This comment has been minimized.

Show comment Hide comment
@iqiancheng

iqiancheng Feb 3, 2017

it works! thanks!

it works! thanks!

@JohnTian

This comment has been minimized.

Show comment Hide comment
@JohnTian

JohnTian Feb 11, 2017

it works! thanks a lot!

it works! thanks a lot!

@larryli

This comment has been minimized.

Show comment Hide comment
@larryli

larryli Feb 16, 2017

👍

larryli commented Feb 16, 2017

👍

@CommonEra93

This comment has been minimized.

Show comment Hide comment
@CommonEra93

CommonEra93 Mar 2, 2017

这个是http和https 代理把? 如果我想用ssh呢?

这个是http和https 代理把? 如果我想用ssh呢?

@pamzerbhu

This comment has been minimized.

Show comment Hide comment
@pamzerbhu

pamzerbhu Mar 7, 2017

it works!顶一个

it works!顶一个

@whyscience

This comment has been minimized.

Show comment Hide comment
@whyscience

whyscience Mar 14, 2017

按照

#只对github.com
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

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

设置
速度感人!!!
selection_001

whyscience commented Mar 14, 2017

按照

#只对github.com
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

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

设置
速度感人!!!
selection_001

@liuliangsir

This comment has been minimized.

Show comment Hide comment
@liuliangsir

liuliangsir Mar 16, 2017

thx~

thx~

@zhEdward

This comment has been minimized.

Show comment Hide comment
@zhEdward

zhEdward Mar 17, 2017

在天朝 使用 git clone 的正确姿势哇

在天朝 使用 git clone 的正确姿势哇

@godtree94

This comment has been minimized.

Show comment Hide comment
@godtree94

godtree94 Mar 28, 2017

现在什么都要设代理,yum npm git wget...天朝.........................................

现在什么都要设代理,yum npm git wget...天朝.........................................

@watsy0007

This comment has been minimized.

Show comment Hide comment
@watsy0007

watsy0007 Mar 28, 2017

thanks @itolfh

thanks @itolfh

@leetking

This comment has been minimized.

Show comment Hide comment
@leetking

leetking Mar 28, 2017

我如此设置之后clone gist同样没有被代理

git设置

[http]
    proxy = socks5://127.0.0.1:1080
[https]
    proxy = socks5://127.0.0.1:1080

本地ss5端口

$ nmap localhost
Starting Nmap 7.01 ( https://nmap.org ) at 2017-03-28 23:05 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000035s latency).
Not shown: 998 closed ports
PORT     STATE SERVICE
1080/tcp open  socks

Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds

ss查看开放端口信息

$ ss -tln | grep 1080
LISTEN     0      128    127.0.0.1:1080                     *:* 

我确信ss5已经打开并且能用,毕竟浏览器能用。
但是在

$ git clone https://gist.github.com/666dd7b27e9116faece6.git
正克隆到 '666dd7b27e9116faece6'...
fatal: unable to access 'https://gist.github.com/666dd7b27e9116faece6.git/': gnutls_handshake() failed: The TLS connection was non-properly terminated.

出现如上错误,我不知道是不是我的git设置问题呢。在这里提问抱歉了。我也google搜索了很久,只有在您这里提到了设置ss5。
谢谢

我如此设置之后clone gist同样没有被代理

git设置

[http]
    proxy = socks5://127.0.0.1:1080
[https]
    proxy = socks5://127.0.0.1:1080

本地ss5端口

$ nmap localhost
Starting Nmap 7.01 ( https://nmap.org ) at 2017-03-28 23:05 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000035s latency).
Not shown: 998 closed ports
PORT     STATE SERVICE
1080/tcp open  socks

Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds

ss查看开放端口信息

$ ss -tln | grep 1080
LISTEN     0      128    127.0.0.1:1080                     *:* 

我确信ss5已经打开并且能用,毕竟浏览器能用。
但是在

$ git clone https://gist.github.com/666dd7b27e9116faece6.git
正克隆到 '666dd7b27e9116faece6'...
fatal: unable to access 'https://gist.github.com/666dd7b27e9116faece6.git/': gnutls_handshake() failed: The TLS connection was non-properly terminated.

出现如上错误,我不知道是不是我的git设置问题呢。在这里提问抱歉了。我也google搜索了很久,只有在您这里提到了设置ss5。
谢谢

@Ivicelsbak

This comment has been minimized.

Show comment Hide comment
@Ivicelsbak

Ivicelsbak Apr 4, 2017

@leetking
git config --global http.proxy 'socks5://127.0.0.1:1080

@leetking
git config --global http.proxy 'socks5://127.0.0.1:1080

@dkzwm

This comment has been minimized.

Show comment Hide comment
@raidsan

This comment has been minimized.

Show comment Hide comment
@raidsan

raidsan Apr 21, 2017

注意: 代理地址不要加引号!
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
大部分网站下载没问题, 但是遇到 gclient 下载会出错, 去掉引号号后成功

raidsan commented Apr 21, 2017

注意: 代理地址不要加引号!
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
大部分网站下载没问题, 但是遇到 gclient 下载会出错, 去掉引号号后成功

@luckyandyzhang

This comment has been minimized.

Show comment Hide comment
@luckyandyzhang

luckyandyzhang May 3, 2017

thanks for sharing.

thanks for sharing.

@leetintin

This comment has been minimized.

Show comment Hide comment
@leetintin

leetintin Jun 17, 2017

thanks!LOL!

thanks!LOL!

@zhangle1

This comment has been minimized.

Show comment Hide comment
@zhangle1

zhangle1 Jun 19, 2017

问下 我想代理 git://git.com 这种开头应该怎么加 ,试了下 不行

问下 我想代理 git://git.com 这种开头应该怎么加 ,试了下 不行

@hippasus

This comment has been minimized.

Show comment Hide comment
@hippasus

hippasus Jun 26, 2017

@zhangle1 使用 git@xxoo.com 这种方式,是用的 SSH 协议。需要在 ~/.ssh/config 目录下配置

Host xxoo.com(改成你的站点)
ProxyCommand connect -H 127.0.0.1:1080 %h %p

@zhangle1 使用 git@xxoo.com 这种方式,是用的 SSH 协议。需要在 ~/.ssh/config 目录下配置

Host xxoo.com(改成你的站点)
ProxyCommand connect -H 127.0.0.1:1080 %h %p

@Jimmy-Z

This comment has been minimized.

Show comment Hide comment
@Jimmy-Z

Jimmy-Z Aug 3, 2017

补充两点:
1, https.proxy设置是无用的, 只需要设置http.proxy
2, socks5h://更好, 远端DNS

Jimmy-Z commented Aug 3, 2017

补充两点:
1, https.proxy设置是无用的, 只需要设置http.proxy
2, socks5h://更好, 远端DNS

@Skura23

This comment has been minimized.

Show comment Hide comment
@Skura23

Skura23 Aug 22, 2017

请问带s和不带s有什么区别

Skura23 commented Aug 22, 2017

请问带s和不带s有什么区别

@8enet

This comment has been minimized.

Show comment Hide comment
@8enet

8enet Sep 21, 2017

对于使用git@协议的,可以配置socks5代理
在~/.ssh/config 文件后面添加几行,没有可以新建一个

Host github.com
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p

8enet commented Sep 21, 2017

对于使用git@协议的,可以配置socks5代理
在~/.ssh/config 文件后面添加几行,没有可以新建一个

Host github.com
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
@ZoeShaw101

This comment has been minimized.

Show comment Hide comment
@ZoeShaw101

ZoeShaw101 Oct 8, 2017

为什么我设置了代理还是会time out

为什么我设置了代理还是会time out

@modifMX

This comment has been minimized.

Show comment Hide comment
@modifMX

modifMX Dec 28, 2017

为什么我设置了代理还是会time out 我也是

modifMX commented Dec 28, 2017

为什么我设置了代理还是会time out 我也是

@erguotou520

This comment has been minimized.

Show comment Hide comment
@erguotou520

erguotou520 Jan 4, 2018

windows 按照 itolfh 说的可以成功

windows 按照 itolfh 说的可以成功

@lolosssss

This comment has been minimized.

Show comment Hide comment
@lolosssss

lolosssss Jan 24, 2018

多次 set/unset 之后, 通过 git config --global -e 可以看到有好多空的 [http], [https]
screen shot 2018-01-24 at 2 08 32 pm

怎么能够不产生多余的内容?

多次 set/unset 之后, 通过 git config --global -e 可以看到有好多空的 [http], [https]
screen shot 2018-01-24 at 2 08 32 pm

怎么能够不产生多余的内容?

@hbshun

This comment has been minimized.

Show comment Hide comment
@hbshun

hbshun Mar 20, 2018

thanks @itolfh

hbshun commented Mar 20, 2018

thanks @itolfh

@b1ueb1ues

This comment has been minimized.

Show comment Hide comment
@b1ueb1ues

b1ueb1ues Mar 23, 2018

https.proxy 根本就不存在这个设置好吗
只有http.proxy是正确的 他负责所有的http[s]代理设置

https.proxy 根本就不存在这个设置好吗
只有http.proxy是正确的 他负责所有的http[s]代理设置

@VOID001

This comment has been minimized.

Show comment Hide comment
@VOID001

VOID001 Mar 29, 2018

git 是没有 https 这个 config section 的
如果想要使用SOCKS5代理的话只需要
git config --global http.proxy "socks5h://your_addr:your_port" 即可

VOID001 commented Mar 29, 2018

git 是没有 https 这个 config section 的
如果想要使用SOCKS5代理的话只需要
git config --global http.proxy "socks5h://your_addr:your_port" 即可

@guclan

This comment has been minimized.

Show comment Hide comment
@guclan

guclan Apr 3, 2018

git 的 ssh 代理终于在这里找到了答案 万分感谢

guclan commented Apr 3, 2018

git 的 ssh 代理终于在这里找到了答案 万分感谢

@XinzeZhang

This comment has been minimized.

Show comment Hide comment
@XinzeZhang

XinzeZhang Apr 12, 2018

在windows上,在Git Bash里设置

ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p

会报错的,提示:

/usr/bin/bash: line 0: exec: nc: not found

因为这个bash是不带netcat的,也就找到不到nc命令。
在win10上,有的msysgit版本集成了connect工具,所以在windows上,可以把ssh的config文件设置为:

Host github.com
ProxyCommand connect -S 127.0.0.1:1080 %h %p

就可以给ssh加socks代理了。

XinzeZhang commented Apr 12, 2018

在windows上,在Git Bash里设置

ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p

会报错的,提示:

/usr/bin/bash: line 0: exec: nc: not found

因为这个bash是不带netcat的,也就找到不到nc命令。
在win10上,有的msysgit版本集成了connect工具,所以在windows上,可以把ssh的config文件设置为:

Host github.com
ProxyCommand connect -S 127.0.0.1:1080 %h %p

就可以给ssh加socks代理了。

@albb762

This comment has been minimized.

Show comment Hide comment
@albb762

albb762 Apr 13, 2018

If it doesn't work,
git config --global -e
del empty [http], [https]

albb762 commented Apr 13, 2018

If it doesn't work,
git config --global -e
del empty [http], [https]

@vipzrx

This comment has been minimized.

Show comment Hide comment
@vipzrx

vipzrx Apr 17, 2018

@whyscience

按照

#只对github.com
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

#取消代理
git config --global --unset http.https://github.com.proxy)
设置
速度感人!!!

git config --global --unset http.https://github.com.proxy) 多了一个 )

vipzrx commented Apr 17, 2018

@whyscience

按照

#只对github.com
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

#取消代理
git config --global --unset http.https://github.com.proxy)
设置
速度感人!!!

git config --global --unset http.https://github.com.proxy) 多了一个 )

@Yaphatesheart

This comment has been minimized.

Show comment Hide comment
@Yaphatesheart

Yaphatesheart Apr 20, 2018

thx

thx

@zhxengx

This comment has been minimized.

Show comment Hide comment
@zhxengx

zhxengx Apr 26, 2018

@Jimmy-Z socks5h效果提升太明显

zhxengx commented Apr 26, 2018

@Jimmy-Z socks5h效果提升太明显

@XxYyKk

This comment has been minimized.

Show comment Hide comment
@XxYyKk

XxYyKk May 1, 2018

为什么我还是不行啊 socks代理127.0.0.1:1080

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

https加上也不行
都是
: gnutls_handshake() failed: The TLS connection was non-properly terminated.

XxYyKk commented May 1, 2018

为什么我还是不行啊 socks代理127.0.0.1:1080

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

https加上也不行
都是
: gnutls_handshake() failed: The TLS connection was non-properly terminated.

@leegcc

This comment has been minimized.

Show comment Hide comment
@leegcc

leegcc May 2, 2018

@XxYyKk @leetking gnutls_handshake() failed: The TLS connection was non-properly terminated. 这个问题我也遇到,但我按 https://blog.csdn.net/qq_38199832/article/details/77803645 这文章的方式解决了。不知道具体什么情况。。。

leegcc commented May 2, 2018

@XxYyKk @leetking gnutls_handshake() failed: The TLS connection was non-properly terminated. 这个问题我也遇到,但我按 https://blog.csdn.net/qq_38199832/article/details/77803645 这文章的方式解决了。不知道具体什么情况。。。

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