Skip to content
@laispace

laispace/git 设置和取消代理

Last active 8 hours agoReport abuse
Embed
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
@mikicomo

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@mikicomo

mikicomo on 20 Dec 2015

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

Copy link Report content

mikicomo commented on 20 Dec 2015

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

@itolfh

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@itolfh

itolfh on 13 Jan 2016

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

Copy link Report content

itolfh commented on 13 Jan 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
Copy link Report content
@chunxiao369
Copy link Report content

chunxiao369 commented on 8 May 2016

Thanks!

@zhuyingda

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@zhuyingda

zhuyingda on 28 Sep 2016

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

Copy link Report content

zhuyingda commented on 28 Sep 2016

请问一下,我只设置了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
Copy link Report content
@tolbkni

tolbkni on 26 Oct 2016

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

Copy link Report content

tolbkni commented on 26 Oct 2016

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

@joydragon-wang

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@joydragon-wang

joydragon-wang on 31 Oct 2016

It works. Thank you very much.

Copy link Report content

joydragon-wang commented on 31 Oct 2016

It works. Thank you very much.

@bit-rocket

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@bit-rocket

bit-rocket on 6 Nov 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

Copy link Report content

bit-rocket commented on 6 Nov 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

@AStogov

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@AStogov

AStogov on 7 Nov 2016

thanks a lot

Copy link Report content

AStogov commented on 7 Nov 2016

thanks a lot

@xuinvip

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@xuinvip
Copy link Report content

xuinvip commented on 11 Dec 2016

thanks!

@BobLiu20

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@BobLiu20

BobLiu20 on 11 Jan 2017

thanks! Working for me.

Copy link Report content

BobLiu20 commented on 11 Jan 2017

thanks! Working for me.

@iTofu

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@iTofu

iTofu on 13 Jan 2017

Thank you! It works for me.

Copy link Report content

iTofu commented on 13 Jan 2017

Thank you! It works for me.

@iqiancheng

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@iqiancheng

iqiancheng on 3 Feb 2017

it works! thanks!

Copy link Report content

iqiancheng commented on 3 Feb 2017

it works! thanks!

@JohnTian

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@JohnTian

JohnTian on 11 Feb 2017

it works! thanks a lot!

Copy link Report content

JohnTian commented on 11 Feb 2017

it works! thanks a lot!

@larryli

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@larryli
Copy link Report content

larryli commented on 16 Feb 2017

👍

@CommonEra93

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@CommonEra93

CommonEra93 on 2 Mar 2017

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

Copy link Report content

CommonEra93 commented on 2 Mar 2017

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

@pamzerbhu

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@pamzerbhu

pamzerbhu on 7 Mar 2017

it works!顶一个

Copy link Report content

pamzerbhu commented on 7 Mar 2017

it works!顶一个

@whyscience

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@whyscience

whyscience on 14 Mar 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

Copy link Report content

whyscience commented on 14 Mar 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
Copy link Report content
@liuliangsir
Copy link Report content

liuliangsir commented on 16 Mar 2017

thx~

@zhEdward

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@zhEdward

zhEdward on 17 Mar 2017

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

Copy link Report content

zhEdward commented on 17 Mar 2017

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

@godtree94

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@godtree94

godtree94 on 28 Mar 2017

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

Copy link Report content

godtree94 commented on 28 Mar 2017

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

@watsy0007

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@watsy0007
Copy link Report content

watsy0007 commented on 28 Mar 2017

thanks @itolfh

@leetking

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@leetking

leetking on 28 Mar 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。
谢谢

Copy link Report content

leetking commented on 28 Mar 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。
谢谢

@Ivicelsbak

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@Ivicelsbak

Ivicelsbak on 5 Apr 2017

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

Copy link Report content

Ivicelsbak commented on 5 Apr 2017

@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
Copy link Report content
@raidsan

raidsan on 21 Apr 2017

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

Copy link Report content

raidsan commented on 21 Apr 2017

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

@andydevacc

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@andydevacc

andydevacc on 3 May 2017

thanks for sharing.

Copy link Report content

andydevacc commented on 3 May 2017

thanks for sharing.

@leetintin

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@leetintin
Copy link Report content

leetintin commented on 17 Jun 2017

thanks!LOL!

@zhangle1

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@zhangle1

zhangle1 on 19 Jun 2017

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

Copy link Report content

zhangle1 commented on 19 Jun 2017

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

@hippasus

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@hippasus

hippasus on 26 Jun 2017

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

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

Copy link Report content

hippasus commented on 26 Jun 2017

@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
Copy link Report content
@Jimmy-Z

Jimmy-Z on 4 Aug 2017

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

Copy link Report content

Jimmy-Z commented on 4 Aug 2017

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

@Skura23

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@Skura23

Skura23 on 22 Aug 2017

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

Copy link Report content

Skura23 commented on 22 Aug 2017

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

@8enet

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@8enet

8enet on 21 Sep 2017

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

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

8enet commented on 21 Sep 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
Copy link Report content
@ZoeShaw101

ZoeShaw101 on 8 Oct 2017

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

Copy link Report content

ZoeShaw101 commented on 8 Oct 2017

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

@modifMX

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@modifMX

modifMX on 28 Dec 2017

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

Copy link Report content

modifMX commented on 28 Dec 2017

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

@erguotou520

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@erguotou520

erguotou520 on 4 Jan 2018

windows 按照 itolfh 说的可以成功

Copy link Report content

erguotou520 commented on 4 Jan 2018

windows 按照 itolfh 说的可以成功

@lolosssss

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@lolosssss

lolosssss on 24 Jan 2018

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

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

Copy link Report content

lolosssss commented on 24 Jan 2018

多次 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
Copy link Report content
@hbshun
Copy link Report content

hbshun commented on 20 Mar 2018

thanks @itolfh

@b1ueb1ues

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@b1ueb1ues

b1ueb1ues on 23 Mar 2018

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

Copy link Report content

b1ueb1ues commented on 23 Mar 2018

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

@VOID001

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@VOID001

VOID001 on 29 Mar 2018

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

Copy link Report content

VOID001 commented on 29 Mar 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
Copy link Report content
@guclan

guclan on 3 Apr 2018

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

Copy link Report content

guclan commented on 3 Apr 2018

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

@XinzeZhang

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@XinzeZhang

XinzeZhang on 12 Apr 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代理了。

Copy link Report content

XinzeZhang commented on 12 Apr 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
Copy link Report content
@albb762

albb762 on 13 Apr 2018

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

Copy link Report content

albb762 commented on 13 Apr 2018

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

@vipzrx

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@vipzrx

vipzrx on 17 Apr 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) 多了一个 )

Copy link Report content

vipzrx commented on 17 Apr 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
Copy link Report content

Yaphatesheart commented on 20 Apr 2018

thx

@zhxengx

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@zhxengx

zhxengx on 26 Apr 2018

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

Copy link Report content

zhxengx commented on 26 Apr 2018

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

@XxYyKk

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@XxYyKk

XxYyKk on 1 May 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.

Copy link Report content

XxYyKk commented on 1 May 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
Copy link Report content
@leegcc

leegcc on 3 May 2018

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

Copy link Report content

leegcc commented on 3 May 2018

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

@Frederic-Zhou

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@Frederic-Zhou

Frederic-Zhou on 5 Jun 2018

it's work for me .
thx,@itolfh

Copy link Report content

Frederic-Zhou commented on 5 Jun 2018

it's work for me .
thx,@itolfh

@Mod233

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@Mod233

Mod233 on 4 Jul 2018

怎么检查自己是否设置成功啊? 我感觉 git clone 的速度没有变化啊...

Copy link Report content

Mod233 commented on 4 Jul 2018

怎么检查自己是否设置成功啊? 我感觉 git clone 的速度没有变化啊...

@Mod233

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@Mod233

Mod233 on 4 Jul 2018

@whyscience 为何我设置了之后提示 Unable to receive initial SOCKS5 response.
...

Copy link Report content

Mod233 commented on 4 Jul 2018

@whyscience 为何我设置了之后提示 Unable to receive initial SOCKS5 response.
...

@wubuwei

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@wubuwei
Copy link Report content

wubuwei commented on 10 Jul 2018

这里可能对你有帮助 https://www.jianshu.com/p/77f773f492c6

@lxq1

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@lxq1

lxq1 on 20 Jul 2018

在Windows7系统下,我是用的 SSH 协议。需要在 用户根目录/.ssh/config 文件下配置,没有config的话就自行创建。

Host github.com
ProxyCommand connect -H 127.0.0.1:1080 %h 22

测试成功使用socks5

Copy link Report content

lxq1 commented on 20 Jul 2018

在Windows7系统下,我是用的 SSH 协议。需要在 用户根目录/.ssh/config 文件下配置,没有config的话就自行创建。

Host github.com
ProxyCommand connect -H 127.0.0.1:1080 %h 22

测试成功使用socks5

@YinAoXiong

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@YinAoXiong

YinAoXiong on 3 Aug 2018

原来ssh需要另外设置,现在才发现难怪https和ssh差那么多

Copy link Report content

YinAoXiong commented on 3 Aug 2018

原来ssh需要另外设置,现在才发现难怪https和ssh差那么多

@congliucong

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@congliucong

congliucong on 7 Aug 2018

已经成功~谢谢

Copy link Report content

congliucong commented on 7 Aug 2018

已经成功~谢谢

@lllunaticer

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@lllunaticer

lllunaticer on 17 Oct 2018

My git works when i do as@itolfh says, thanks

Copy link Report content

lllunaticer commented on 17 Oct 2018

My git works when i do as@itolfh says, thanks

@vkso

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@vkso

vkso on 24 Oct 2018

There are two ways to clone in GitHub.

  1. Clone with HTTPS: git clone https://github.com/xxx/xxx.git
  2. Clone with SSH: git clone git@github.com:xxx/xxx.git

If you don't set up a proxy for local SSH, cloning using SSH will not take the proxy.
If you want to use the socks5 proxy, you only need one command
git config --global http.proxy socks5://your-server:your-port
Unset proxy:
git config --global --unset http.proxy
It works in my Ubuntu 16.04.

Copy link Report content

vkso commented on 24 Oct 2018

There are two ways to clone in GitHub.

  1. Clone with HTTPS: git clone https://github.com/xxx/xxx.git
  2. Clone with SSH: git clone git@github.com:xxx/xxx.git

If you don't set up a proxy for local SSH, cloning using SSH will not take the proxy.
If you want to use the socks5 proxy, you only need one command
git config --global http.proxy socks5://your-server:your-port
Unset proxy:
git config --global --unset http.proxy
It works in my Ubuntu 16.04.

@wangzhankun

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@wangzhankun

wangzhankun on 3 Dec 2018

按照

#只对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

请问
image
还是报错是为什么呀?我是校园网走ipv6

Copy link Report content

wangzhankun commented on 3 Dec 2018

按照

#只对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

请问
image
还是报错是为什么呀?我是校园网走ipv6

@rangercyh

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@rangercyh

rangercyh on 31 Jan 2019

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

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

就你的方法我成功了。。

Copy link Report content

rangercyh commented on 31 Jan 2019

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

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

就你的方法我成功了。。

@zzqcn

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@zzqcn

zzqcn on 14 Feb 2019

结合以上各位经验设置成功. 以下以macOS为准.

  1. https访问
    仅为github.com设置socks5代理(推荐这种方式, 公司内网就不用设代理了, 多此一举):
    git config --global http.https://github.com.proxy socks5://127.0.0.1:1086
    其中1086是socks5的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1086.
    设置完成后, ~/.gitconfig文件中会增加以下条目:

    [http "https://github.com"]
        proxy = socks5://127.0.0.1:1086
    
  2. ssh访问
    需要修改~/.ssh/config文件, 没有的话新建一个. 同样仅为github.com设置代理:

    Host github.com
        User git
        ProxyCommand nc -v -x 127.0.0.1:1086 %h %p
    

    如果是在Windows下, 则需要个性%home%.ssh\config, 其中内容类似于:

    Host github.com
        User git
        ProxyCommand connect -S 127.0.0.1:1086 %h %p
    

    这里-S表示使用socks5代理, 如果是http代理则为-H. connect工具git自带, 在<Git>\mingw64\bin\下面.

Copy link Report content

zzqcn commented on 14 Feb 2019

结合以上各位经验设置成功. 以下以macOS为准.

  1. https访问
    仅为github.com设置socks5代理(推荐这种方式, 公司内网就不用设代理了, 多此一举):
    git config --global http.https://github.com.proxy socks5://127.0.0.1:1086
    其中1086是socks5的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1086.
    设置完成后, ~/.gitconfig文件中会增加以下条目:

    [http "https://github.com"]
        proxy = socks5://127.0.0.1:1086
    
  2. ssh访问
    需要修改~/.ssh/config文件, 没有的话新建一个. 同样仅为github.com设置代理:

    Host github.com
        User git
        ProxyCommand nc -v -x 127.0.0.1:1086 %h %p
    

    如果是在Windows下, 则需要个性%home%.ssh\config, 其中内容类似于:

    Host github.com
        User git
        ProxyCommand connect -S 127.0.0.1:1086 %h %p
    

    这里-S表示使用socks5代理, 如果是http代理则为-H. connect工具git自带, 在<Git>\mingw64\bin\下面.

@nobita0522

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@nobita0522

nobita0522 on 26 Feb 2019

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

thanks

Copy link Report content

nobita0522 commented on 26 Feb 2019

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

thanks

@smarxpan

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@smarxpan

smarxpan on 3 Mar 2019

设置代理

git config --global http.proxy socks5h://127.0.0.1:1080

取消代理

git config --global --unset http.proxy

因为我用的是shadowsocks代理,所以上面是socks5h://, 如果用的是http代理,将socks5h改为http即可

如果仅仅想为github设置代理,可以这样:

git config --global http.https://github.com.proxy socks5h://127.0.0.1:1080

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

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

windows使用:

Host github.com
User git
ProxyCommand connect -S 127.0.0.1:1080 %h %p
Copy link Report content

smarxpan commented on 3 Mar 2019

设置代理

git config --global http.proxy socks5h://127.0.0.1:1080

取消代理

git config --global --unset http.proxy

因为我用的是shadowsocks代理,所以上面是socks5h://, 如果用的是http代理,将socks5h改为http即可

如果仅仅想为github设置代理,可以这样:

git config --global http.https://github.com.proxy socks5h://127.0.0.1:1080

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

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

windows使用:

Host github.com
User git
ProxyCommand connect -S 127.0.0.1:1080 %h %p
@lindexi

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@lindexi

lindexi on 7 Mar 2019

@whyscience 你的方法有用

Copy link Report content

lindexi commented on 7 Mar 2019

@whyscience 你的方法有用

@liuzhenyulive

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@liuzhenyulive

liuzhenyulive on 20 Mar 2019

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

it worked,thanks

Copy link Report content

liuzhenyulive commented on 20 Mar 2019

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

it worked,thanks

@Skura23

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@Skura23

Skura23 on 30 Mar 2019

本人结合 zzqcn 和 smarxpan两位朋友的配置最后解决了,
尤其是zzqcn 提到的

其中1086是socks5的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1086.

也就是说如果你是用的ss的话, 那么这里的地址就是本机地址127.0.0.1, 端口就是ss在本地的端口,
windows默认是1080, mac是1086, 而我之前一直设置地址和端口是源服务器地址端口, 所以一直不行

另外一点是如果是使用git@协议的链接, 则要配置~/.ssh/config, 否则仅http/https链接代理生效, 上面都有提到

Copy link Report content

Skura23 commented on 30 Mar 2019

本人结合 zzqcn 和 smarxpan两位朋友的配置最后解决了,
尤其是zzqcn 提到的

其中1086是socks5的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1086.

也就是说如果你是用的ss的话, 那么这里的地址就是本机地址127.0.0.1, 端口就是ss在本地的端口,
windows默认是1080, mac是1086, 而我之前一直设置地址和端口是源服务器地址端口, 所以一直不行

另外一点是如果是使用git@协议的链接, 则要配置~/.ssh/config, 否则仅http/https链接代理生效, 上面都有提到

@JokeenZhang

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@JokeenZhang

JokeenZhang on 23 Apr 2019

取消代理也要如下命令吗?

npm config delete proxy

还是说unset就足够了?

Copy link Report content

JokeenZhang commented on 23 Apr 2019

取消代理也要如下命令吗?

npm config delete proxy

还是说unset就足够了?

@shouyong

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@shouyong

shouyong on 17 May 2019

➜  src export https_proxy=socks5://127.0.0.1:1086
➜  src export http_proxy=socks5://127.0.0.1:1086
➜  src git clone https://github.com/xxxx/xxx.git

测试可行!

Copy link Report content

shouyong commented on 17 May 2019

➜  src export https_proxy=socks5://127.0.0.1:1086
➜  src export http_proxy=socks5://127.0.0.1:1086
➜  src git clone https://github.com/xxxx/xxx.git

测试可行!

@onloner2012

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@onloner2012

onloner2012 on 10 Jul 2019

There are two ways to clone in GitHub.

  1. Clone with HTTPS: git clone https://github.com/xxx/xxx.git
  2. Clone with SSH: git clone git@github.com:xxx/xxx.git

If you don't set up a proxy for local SSH, cloning using SSH will not take the proxy.
If you want to use the socks5 proxy, you only need one command
git config --global HTTP.proxy socks5://your-server:your-port
Unset proxy:
git config --global --unset http.proxy
It works in my Ubuntu 16.04.

thx you so much the ,my machine is run also,iam not set SSH 😄 😄

Copy link Report content

onloner2012 commented on 10 Jul 2019

There are two ways to clone in GitHub.

  1. Clone with HTTPS: git clone https://github.com/xxx/xxx.git
  2. Clone with SSH: git clone git@github.com:xxx/xxx.git

If you don't set up a proxy for local SSH, cloning using SSH will not take the proxy.
If you want to use the socks5 proxy, you only need one command
git config --global HTTP.proxy socks5://your-server:your-port
Unset proxy:
git config --global --unset http.proxy
It works in my Ubuntu 16.04.

thx you so much the ,my machine is run also,iam not set SSH 😄 😄

@liloli

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@liloli

liloli on 29 Jul 2019

This post helps a lot, thx everyone! :)

Copy link Report content

liloli commented on 29 Jul 2019

This post helps a lot, thx everyone! :)

@yangxuanx

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@yangxuanx

yangxuanx on 9 Oct 2019

针对archlinux 默认没有安装netcat,仓库有两个netcat,gnu和openbsd,装openbsd-netcat,就对了

sudo pacman -S openbsd-netcat
Copy link Report content

yangxuanx commented on 9 Oct 2019

针对archlinux 默认没有安装netcat,仓库有两个netcat,gnu和openbsd,装openbsd-netcat,就对了

sudo pacman -S openbsd-netcat
@alancprc

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@alancprc

alancprc on 15 Oct 2019

针对archlinux 默认没有安装netcat,仓库有两个netcat,gnu和openbsd,装openbsd-netcat,就对了

sudo pacman -S openbsd-netcat

thanks!

Copy link Report content

alancprc commented on 15 Oct 2019

针对archlinux 默认没有安装netcat,仓库有两个netcat,gnu和openbsd,装openbsd-netcat,就对了

sudo pacman -S openbsd-netcat

thanks!

@baddate

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@baddate

baddate on 15 Oct 2019

git 是没有 https 这个 config section 的
如果想要使用SOCKS5代理的话只需要
git config --global http.proxy "socks5h://your_addr:your_port" 即可
为什么我这样设置,git push还是很慢啊

Copy link Report content

baddate commented on 15 Oct 2019

git 是没有 https 这个 config section 的
如果想要使用SOCKS5代理的话只需要
git config --global http.proxy "socks5h://your_addr:your_port" 即可
为什么我这样设置,git push还是很慢啊

@LittleBreak

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@LittleBreak

LittleBreak on 18 Oct 2019

使用git@github.com:xxx.git clone时,提示

Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


应该怎么解决啊

Copy link Report content

LittleBreak commented on 18 Oct 2019

使用git@github.com:xxx.git clone时,提示

Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


应该怎么解决啊

@shouyong

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@shouyong

shouyong on 21 Oct 2019

使用git@github.com:xxx.git clone时,提示

Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

应该怎么解决啊

换成https开头的地址;

Copy link Report content

shouyong commented on 21 Oct 2019

使用git@github.com:xxx.git clone时,提示

Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

应该怎么解决啊

换成https开头的地址;

@devinor

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@devinor
Copy link Report content

devinor commented on 22 Oct 2019

thanks

@sanjayzzzhong

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@sanjayzzzhong

sanjayzzzhong on 24 Oct 2019

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

thanks

Copy link Report content

sanjayzzzhong commented on 24 Oct 2019

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

thanks

@yanxijian

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@yanxijian

yanxijian on 6 Nov 2019

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

  1. 确实设置http.proxy就可以了 (git config --global https.proxy http://127.0.0.1:1080)
  2. 我这里设置socks5时,push会提示:The ServicePointManager does not support proxies with the socks5 scheme. 需要输入账号和密码才能push
Copy link Report content

yanxijian commented on 6 Nov 2019

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

  1. 确实设置http.proxy就可以了 (git config --global https.proxy http://127.0.0.1:1080)
  2. 我这里设置socks5时,push会提示:The ServicePointManager does not support proxies with the socks5 scheme. 需要输入账号和密码才能push
@nepaul

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@nepaul

nepaul on 12 Nov 2019

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

Copy link Report content

nepaul commented on 12 Nov 2019

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

@sanjayzzzhong

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@sanjayzzzhong

sanjayzzzhong on 13 Nov 2019

我个人觉得不需要单独配置git的代理, 因为之前这样子配导致我的mac上用brew总是走代理, 找了好久才发现问题
因此我个人推荐每开一终端, 需要用到代理的时候再打开终端并输入一下shell语句:

# 如果你的代理走的是sock5 用这个
export ALL_PROXY=socks5://127.0.0.1:1080

或者

# 如果你的代理走的是http 用这个
export ALL_PROXY=http://127.0.0.1:1080

这样的配置仅针对当前终端, 如果新开一个终端就没有走代理.
单独为git设置代理的话, 会在git的配置文件里添加代理, 有时候难以定位错误.
希望我的建议能够帮助到各位~

Copy link Report content

sanjayzzzhong commented on 13 Nov 2019

我个人觉得不需要单独配置git的代理, 因为之前这样子配导致我的mac上用brew总是走代理, 找了好久才发现问题
因此我个人推荐每开一终端, 需要用到代理的时候再打开终端并输入一下shell语句:

# 如果你的代理走的是sock5 用这个
export ALL_PROXY=socks5://127.0.0.1:1080

或者

# 如果你的代理走的是http 用这个
export ALL_PROXY=http://127.0.0.1:1080

这样的配置仅针对当前终端, 如果新开一个终端就没有走代理.
单独为git设置代理的话, 会在git的配置文件里添加代理, 有时候难以定位错误.
希望我的建议能够帮助到各位~

@nepaul

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@nepaul

nepaul on 13 Nov 2019

我个人觉得不需要单独配置git的代理, 因为之前这样子配导致我的mac上用brew总是走代理, 找了好久才发现问题
因此我个人推荐每开一终端, 需要用到代理的时候再打开终端并输入一下shell语句:

# 如果你的代理走的是sock5 用这个
export ALL_PROXY=socks5://127.0.0.1:1080

或者

# 如果你的代理走的是http 用这个
export ALL_PROXY=http://127.0.0.1:1080

这样的配置仅针对当前终端, 如果新开一个终端就没有走代理.
单独为git设置代理的话, 会在git的配置文件里添加代理, 有时候难以定位错误.
希望我的建议能够帮助到各位~

👍👍

Copy link Report content

nepaul commented on 13 Nov 2019

我个人觉得不需要单独配置git的代理, 因为之前这样子配导致我的mac上用brew总是走代理, 找了好久才发现问题
因此我个人推荐每开一终端, 需要用到代理的时候再打开终端并输入一下shell语句:

# 如果你的代理走的是sock5 用这个
export ALL_PROXY=socks5://127.0.0.1:1080

或者

# 如果你的代理走的是http 用这个
export ALL_PROXY=http://127.0.0.1:1080

这样的配置仅针对当前终端, 如果新开一个终端就没有走代理.
单独为git设置代理的话, 会在git的配置文件里添加代理, 有时候难以定位错误.
希望我的建议能够帮助到各位~

👍👍

@lucifer717

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@lucifer717

lucifer717 on 13 Nov 2019

打开自己的ss客户端,看下http代理的端口,我的1087并不是1080,别被误导了

Copy link Report content

lucifer717 commented on 13 Nov 2019

打开自己的ss客户端,看下http代理的端口,我的1087并不是1080,别被误导了

@yangruihan

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@yangruihan

yangruihan on 22 Nov 2019

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

为什么要加引号呢,我加了引号反而有问题,去掉引号成功了

Copy link Report content

yangruihan commented on 22 Nov 2019

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

为什么要加引号呢,我加了引号反而有问题,去掉引号成功了

@HarborZeng

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@HarborZeng

HarborZeng on 7 Dec 2019

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

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

谢谢 可以用于windows10

Copy link Report content

HarborZeng commented on 7 Dec 2019

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

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

谢谢 可以用于windows10

@HarborZeng

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@HarborZeng

HarborZeng on 7 Dec 2019

For those who use linux system like centos, debian or deepin, if there are problems with nc -X, you can chose connect-proxy, intorduced https://stackoverflow.com/questions/19161960/connect-with-ssh-through-a-proxy

Just use

$ sudo apt install connect-proxy -y

and then edit your ~/.ssh/config as following:

Host github.com
User git
ProxyCommand connect-proxy -S 127.0.0.1:1080 %h %p
Copy link Report content

HarborZeng commented on 7 Dec 2019

For those who use linux system like centos, debian or deepin, if there are problems with nc -X, you can chose connect-proxy, intorduced https://stackoverflow.com/questions/19161960/connect-with-ssh-through-a-proxy

Just use

$ sudo apt install connect-proxy -y

and then edit your ~/.ssh/config as following:

Host github.com
User git
ProxyCommand connect-proxy -S 127.0.0.1:1080 %h %p
@iSteveyang

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@iSteveyang

iSteveyang on 21 Dec 2019

git config --global http.https://github.com.proxy socks5://127.0.0.1:

大佬NB

Copy link Report content

iSteveyang commented on 21 Dec 2019

git config --global http.https://github.com.proxy socks5://127.0.0.1:

大佬NB

@liuzhenyulive

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@liuzhenyulive

liuzhenyulive on 28 Dec 2019

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 http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080

Copy link Report content

liuzhenyulive commented on 28 Dec 2019

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 http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080

@E1sewhere

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@E1sewhere

E1sewhere on 26 Jan 2020

我也是,win10,本地使用的v2ray做代理:socks5端口维1079,http端口为1080,
为git设置了代理

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

然后又在gitconfig里查看,确实把代理添加好了.
git里使用命令

curl www.google.com

timeout,同时监听代理完全没有对google的请求,基本可以断定git的请求没有走代理.
用同样的方法在cmd里设置了代理,cmd可以成功访问到google.

不知道我是什么问题,我也在.ssh内添加了config文件并按评论设置了内容,依然timeout.

Copy link Report content

E1sewhere commented on 26 Jan 2020

我也是,win10,本地使用的v2ray做代理:socks5端口维1079,http端口为1080,
为git设置了代理

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

然后又在gitconfig里查看,确实把代理添加好了.
git里使用命令

curl www.google.com

timeout,同时监听代理完全没有对google的请求,基本可以断定git的请求没有走代理.
用同样的方法在cmd里设置了代理,cmd可以成功访问到google.

不知道我是什么问题,我也在.ssh内添加了config文件并按评论设置了内容,依然timeout.

@sanjayzzzhong

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@sanjayzzzhong

sanjayzzzhong on 26 Jan 2020

我也是,win10,本地使用的v2ray做代理:socks5端口维1079,http端口为1080,
为git设置了代理

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

然后又在gitconfig里查看,确实把代理添加好了.
git里使用命令

curl www.google.com

timeout,同时监听代理完全没有对google的请求,基本可以断定git的请求没有走代理.
用同样的方法在cmd里设置了代理,cmd可以成功访问到google.

不知道我是什么问题,我也在.ssh内添加了config文件并按评论设置了内容,依然timeout.

在git里使用命令,是指用win10下的git bash那个终端吗?还是指什么?

Copy link Report content

sanjayzzzhong commented on 26 Jan 2020

我也是,win10,本地使用的v2ray做代理:socks5端口维1079,http端口为1080,
为git设置了代理

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

然后又在gitconfig里查看,确实把代理添加好了.
git里使用命令

curl www.google.com

timeout,同时监听代理完全没有对google的请求,基本可以断定git的请求没有走代理.
用同样的方法在cmd里设置了代理,cmd可以成功访问到google.

不知道我是什么问题,我也在.ssh内添加了config文件并按评论设置了内容,依然timeout.

在git里使用命令,是指用win10下的git bash那个终端吗?还是指什么?

@E1sewhere

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@E1sewhere

E1sewhere on 29 Jan 2020

我也是,win10,本地使用的v2ray做代理:socks5端口维1079,http端口为1080,
为git设置了代理

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

然后又在gitconfig里查看,确实把代理添加好了.
git里使用命令

curl www.google.com

timeout,同时监听代理完全没有对google的请求,基本可以断定git的请求没有走代理.
用同样的方法在cmd里设置了代理,cmd可以成功访问到google.
不知道我是什么问题,我也在.ssh内添加了config文件并按评论设置了内容,依然timeout.

在git里使用命令,是指用win10下的git bash那个终端吗?还是指什么?

git bash,已经解决,换了shocks协议,可以连上github了

Copy link Report content

E1sewhere commented on 29 Jan 2020

我也是,win10,本地使用的v2ray做代理:socks5端口维1079,http端口为1080,
为git设置了代理

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

然后又在gitconfig里查看,确实把代理添加好了.
git里使用命令

curl www.google.com

timeout,同时监听代理完全没有对google的请求,基本可以断定git的请求没有走代理.
用同样的方法在cmd里设置了代理,cmd可以成功访问到google.
不知道我是什么问题,我也在.ssh内添加了config文件并按评论设置了内容,依然timeout.

在git里使用命令,是指用win10下的git bash那个终端吗?还是指什么?

git bash,已经解决,换了shocks协议,可以连上github了

@Atuna

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@Atuna

Atuna on 17 Feb 2020

结合以上各位经验设置成功. 以下以macOS为准.

  1. https访问
    仅为github.com设置socks5代理(推荐这种方式, 公司内网就不用设代理了, 多此一举):
    git config --global http.https://github.com.proxy socks5://127.0.0.1:1086
    其中1086是socks5的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1086.
    设置完成后, ~/.gitconfig文件中会增加以下条目:

    [http "https://github.com"]
        proxy = socks5://127.0.0.1:1086
    
  2. ssh访问
    需要修改~/.ssh/config文件, 没有的话新建一个. 同样仅为github.com设置代理:

    Host github.com
        User git
        ProxyCommand nc -v -x 127.0.0.1:1086 %h %p
    

    如果是在Windows下, 则需要个性%home%.ssh\config, 其中内容类似于:

    Host github.com
        User git
        ProxyCommand connect -S 127.0.0.1:1086 %h %p
    

    这里-S表示使用socks5代理, 如果是http代理则为-H. connect工具git自带, 在\mingw64\bin\下面.

总结的很好,已经成功了,感谢!
我是用的git clone git@github.com/xxx,实际生效的命令是:

Host github.com
    User git
    ProxyCommand connect -S 127.0.0.1:1086 %h %p

没有测试过但git clone https://github.com/xxx,的话应该是需要:

git config --global http.https://github.com.proxy socks5://127.0.0.1:1086

Copy link Report content

Atuna commented on 17 Feb 2020

结合以上各位经验设置成功. 以下以macOS为准.

  1. https访问
    仅为github.com设置socks5代理(推荐这种方式, 公司内网就不用设代理了, 多此一举):
    git config --global http.https://github.com.proxy socks5://127.0.0.1:1086
    其中1086是socks5的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1086.
    设置完成后, ~/.gitconfig文件中会增加以下条目:

    [http "https://github.com"]
        proxy = socks5://127.0.0.1:1086
    
  2. ssh访问
    需要修改~/.ssh/config文件, 没有的话新建一个. 同样仅为github.com设置代理:

    Host github.com
        User git
        ProxyCommand nc -v -x 127.0.0.1:1086 %h %p
    

    如果是在Windows下, 则需要个性%home%.ssh\config, 其中内容类似于:

    Host github.com
        User git
        ProxyCommand connect -S 127.0.0.1:1086 %h %p
    

    这里-S表示使用socks5代理, 如果是http代理则为-H. connect工具git自带, 在\mingw64\bin\下面.

总结的很好,已经成功了,感谢!
我是用的git clone git@github.com/xxx,实际生效的命令是:

Host github.com
    User git
    ProxyCommand connect -S 127.0.0.1:1086 %h %p

没有测试过但git clone https://github.com/xxx,的话应该是需要:

git config --global http.https://github.com.proxy socks5://127.0.0.1:1086

@liuweiGL

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@liuweiGL

liuweiGL on 4 Mar 2020

在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代理了。

👍👍👍

Copy link Report content

liuweiGL commented on 4 Mar 2020

在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代理了。

👍👍👍

@chengyi

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@chengyi

chengyi on 18 Mar 2020

用proxychains呢🤣

Copy link Report content

chengyi commented on 18 Mar 2020

用proxychains呢🤣

@BatterToMe

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@BatterToMe

BatterToMe on 18 Mar 2020

http/https不行的,记得确认一下本地代理工具有没有打开http代理

Copy link Report content

BatterToMe commented on 18 Mar 2020

http/https不行的,记得确认一下本地代理工具有没有打开http代理

@weaming

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@weaming

weaming on 20 Mar 2020

基于Trojan的代理需要双引号,git config --global http.proxy "socks5://127.0.0.1:1080"

说不通,这个配置是在ssh这边的,跟使用ss还是trojan没有关系

Copy link Report content

weaming commented on 20 Mar 2020

基于Trojan的代理需要双引号,git config --global http.proxy "socks5://127.0.0.1:1080"

说不通,这个配置是在ssh这边的,跟使用ss还是trojan没有关系

@1725636955

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@1725636955

1725636955 on 20 Mar 2020

基于Trojan的代理需要双引号,git config --global http.proxy“ socks5://127.0.0.1:1080”

说不通,这个配置是在ssh这边的,跟使用ss还是trojan没有关系

单引号不行,

Copy link Report content

1725636955 commented on 20 Mar 2020

基于Trojan的代理需要双引号,git config --global http.proxy“ socks5://127.0.0.1:1080”

说不通,这个配置是在ssh这边的,跟使用ss还是trojan没有关系

单引号不行,

@qiuhaha

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@qiuhaha

qiuhaha on 26 Mar 2020

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

Copy link Report content

qiuhaha commented on 26 Mar 2020

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

@Hunu

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@Hunu

Hunu on 28 Mar 2020

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

太NB了,smarxpan 大神的方法解决了我数年的困扰!

git clone with ssh using Socks5 proxy: 亲测有效

Copy link Report content

Hunu commented on 28 Mar 2020

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

太NB了,smarxpan 大神的方法解决了我数年的困扰!

git clone with ssh using Socks5 proxy: 亲测有效

@OsbertWang

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@OsbertWang

OsbertWang on 25 Apr 2020

仿照上面的内容写了以下配置方案,操作系统是 win 10,代理用 SSR,端口 1080。
先设置了

git config --global http.https://github.com.proxy socks5h://127.0.0.1:1080

接着用

git config --global --get http.https://github.com.proxy

得到反馈

socks5h://127.0.0.1:1080

说明设置成功。
下面在用户文件夹的 .ssh 中建立 config 文件,内容为

ProxyCommand connect -S 127.0.0.1:1080 -a none %h %p

Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile "C:\Users\****\.ssh\id_rsa"
  TCPKeepAlive yes
  ServerAliveInterval 600
  IPQoS=throughput
  ServerAliveCountMax 120

Host ssh.github.com
  User git
  Port 443
  Hostname ssh.github.com
  IdentityFile "C:\Users\****\.ssh\id_rsa"
  TCPKeepAlive yes
  ServerAliveInterval 600
  IPQoS=throughput
  ServerAliveCountMax 120

注意****要换成用户自己的名称。
此配置单参考这里这里

Copy link Report content

OsbertWang commented on 25 Apr 2020

仿照上面的内容写了以下配置方案,操作系统是 win 10,代理用 SSR,端口 1080。
先设置了

git config --global http.https://github.com.proxy socks5h://127.0.0.1:1080

接着用

git config --global --get http.https://github.com.proxy

得到反馈

socks5h://127.0.0.1:1080

说明设置成功。
下面在用户文件夹的 .ssh 中建立 config 文件,内容为

ProxyCommand connect -S 127.0.0.1:1080 -a none %h %p

Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile "C:\Users\****\.ssh\id_rsa"
  TCPKeepAlive yes
  ServerAliveInterval 600
  IPQoS=throughput
  ServerAliveCountMax 120

Host ssh.github.com
  User git
  Port 443
  Hostname ssh.github.com
  IdentityFile "C:\Users\****\.ssh\id_rsa"
  TCPKeepAlive yes
  ServerAliveInterval 600
  IPQoS=throughput
  ServerAliveCountMax 120

注意****要换成用户自己的名称。
此配置单参考这里这里

@gfsdcx1992

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@gfsdcx1992
Copy link Report content

gfsdcx1992 commented on 27 Apr 2020

thx v m

@pcqpcq

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@pcqpcq

pcqpcq on 11 May 2020

just

git config --global http.proxy 127.0.0.1:1080
git config --global https.proxy 127.0.0.1:1080

without http:// or https://

Copy link Report content

pcqpcq commented on 11 May 2020

just

git config --global http.proxy 127.0.0.1:1080
git config --global https.proxy 127.0.0.1:1080

without http:// or https://

@wo4wangle

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@wo4wangle

wo4wangle on 11 May 2020

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

怎么能够不产生多余的内容?
这条帮助了我,之前被覆盖了难受,到这里才能删除

Copy link Report content

wo4wangle commented on 11 May 2020

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

怎么能够不产生多余的内容?
这条帮助了我,之前被覆盖了难受,到这里才能删除

@raymondzhaoy

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@raymondzhaoy
Copy link Report content

raymondzhaoy commented on 4 Jun 2020

thx

@Jade-Zeng

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@Jade-Zeng

Jade-Zeng on 14 Jun 2020

git config --global http.proxy http://127.0.0.1:网络设置里的端口号

git config --global https.proxy https://127.0.0.1:网络设置里的端口号

git config --global --unset http.proxy

git config --global --unset https.proxy
后面的端口号是你电脑走代理之后,在网络设置里的代理的端口号,在电脑的网络设置高级代理里点击http 或 https查看

Copy link Report content

Jade-Zeng commented on 14 Jun 2020

git config --global http.proxy http://127.0.0.1:网络设置里的端口号

git config --global https.proxy https://127.0.0.1:网络设置里的端口号

git config --global --unset http.proxy

git config --global --unset https.proxy
后面的端口号是你电脑走代理之后,在网络设置里的代理的端口号,在电脑的网络设置高级代理里点击http 或 https查看

@liuqinh2s

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@liuqinh2s

liuqinh2s on 18 Jun 2020

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

因为git没有https.proxy这个选项,只有http.proxy,设置了这个,https流量也会走代理

Copy link Report content

liuqinh2s commented on 18 Jun 2020

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

因为git没有https.proxy这个选项,只有http.proxy,设置了这个,https流量也会走代理

@HarborZeng

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@HarborZeng

HarborZeng on 19 Jun 2020

仿照上面的内容写了以下配置方案,操作系统是 win 10,代理用 SSR,端口 1080。
先设置了

git config --global http.https://github.com.proxy socks5h://127.0.0.1:1080

接着用

git config --global --get http.https://github.com.proxy

得到反馈

socks5h://127.0.0.1:1080

说明设置成功。
下面在用户文件夹的 .ssh 中建立 config 文件,内容为

ProxyCommand connect -S 127.0.0.1:1080 -a none %h %p

Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile "C:\Users\****\.ssh\id_rsa"
  TCPKeepAlive yes
  ServerAliveInterval 600
  IPQoS=throughput
  ServerAliveCountMax 120

Host ssh.github.com
  User git
  Port 443
  Hostname ssh.github.com
  IdentityFile "C:\Users\****\.ssh\id_rsa"
  TCPKeepAlive yes
  ServerAliveInterval 600
  IPQoS=throughput
  ServerAliveCountMax 120

注意****要换成用户自己的名称。
此配置单参考这里这里

感谢 这个真的有用

Copy link Report content

HarborZeng commented on 19 Jun 2020

仿照上面的内容写了以下配置方案,操作系统是 win 10,代理用 SSR,端口 1080。
先设置了

git config --global http.https://github.com.proxy socks5h://127.0.0.1:1080

接着用

git config --global --get http.https://github.com.proxy

得到反馈

socks5h://127.0.0.1:1080

说明设置成功。
下面在用户文件夹的 .ssh 中建立 config 文件,内容为

ProxyCommand connect -S 127.0.0.1:1080 -a none %h %p

Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile "C:\Users\****\.ssh\id_rsa"
  TCPKeepAlive yes
  ServerAliveInterval 600
  IPQoS=throughput
  ServerAliveCountMax 120

Host ssh.github.com
  User git
  Port 443
  Hostname ssh.github.com
  IdentityFile "C:\Users\****\.ssh\id_rsa"
  TCPKeepAlive yes
  ServerAliveInterval 600
  IPQoS=throughput
  ServerAliveCountMax 120

注意****要换成用户自己的名称。
此配置单参考这里这里

感谢 这个真的有用

@bao3

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@bao3

bao3 on 20 Jun 2020

我无意间搜到这个,我是想说,我没有设置 git 单独的代理,而是设置 shell 的代理,这样就自动解决了 git / apt /yum 所有这些的网速问题。

另外如果使用 docker,可以通过添加 -e http_proxy=**** -e https_poryx=*** 来让 docker 特定容器支持代理。

Copy link Report content

bao3 commented on 20 Jun 2020

我无意间搜到这个,我是想说,我没有设置 git 单独的代理,而是设置 shell 的代理,这样就自动解决了 git / apt /yum 所有这些的网速问题。

另外如果使用 docker,可以通过添加 -e http_proxy=**** -e https_poryx=*** 来让 docker 特定容器支持代理。

@ghosoft

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@ghosoft

ghosoft on 27 Jun 2020

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

works for me, Thank you!

Copy link Report content

ghosoft commented on 27 Jun 2020

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

works for me, Thank you!

@lfl976

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@lfl976

lfl976 on 10 Jul 2020

good,Thanks

Copy link Report content

lfl976 commented on 10 Jul 2020

good,Thanks

@han88829

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@han88829

han88829 on 20 Jul 2020

[remote "origin"] proxy = socks5://127.0.0.1:1080
我使用v2ray,以上设置对我无用,直接修改proxy可以

Copy link Report content

han88829 commented on 20 Jul 2020

[remote "origin"] proxy = socks5://127.0.0.1:1080
我使用v2ray,以上设置对我无用,直接修改proxy可以

@Jason-Ma-233

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@Jason-Ma-233

Jason-Ma-233 on 21 Jul 2020

git最近更新了socks5的语法,去掉了引号,git config --global http.proxy socks5://127.0.0.1:10808配合V2RayN可用

Copy link Report content

Jason-Ma-233 commented on 21 Jul 2020

git最近更新了socks5的语法,去掉了引号,git config --global http.proxy socks5://127.0.0.1:10808配合V2RayN可用

@65zlui

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@65zlui

65zlui on 25 Jul 2020

按照

#只对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

亲测有效

Copy link Report content

65zlui commented on 25 Jul 2020

按照

#只对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

亲测有效

@HStarrr

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@HStarrr

HStarrr on 30 Jul 2020

在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代理了。

非常棒!这才是正确答案!!!

Copy link Report content

HStarrr commented on 30 Jul 2020

在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代理了。

非常棒!这才是正确答案!!!

@MaxJmac

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@MaxJmac

MaxJmac on 6 Aug 2020

方法管用,就是端口必须改成跟ShadowSocks的Socks5端口一致

Copy link Report content

MaxJmac commented on 6 Aug 2020

方法管用,就是端口必须改成跟ShadowSocks的Socks5端口一致

@Ashappyboy

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@Ashappyboy

Ashappyboy on 14 Aug 2020

git最近更新了socks5的语法,去掉了引号,git config --global http.proxy socks5://127.0.0.1:10808配合V2RayN可用
80是代理服务器开放端口;10808是v2ray本地监听端口,所有git设置这个监听端口;
image
本地这个端口在git内部设置没有意义。
image
直接编辑这个文件ok。
image
image
整体速度为proxy的速度,没有出现*m/s,有点遗憾,谁搞出来可以留言。
best wishes!

Copy link Report content

Ashappyboy commented on 14 Aug 2020

git最近更新了socks5的语法,去掉了引号,git config --global http.proxy socks5://127.0.0.1:10808配合V2RayN可用
80是代理服务器开放端口;10808是v2ray本地监听端口,所有git设置这个监听端口;
image
本地这个端口在git内部设置没有意义。
image
直接编辑这个文件ok。
image
image
整体速度为proxy的速度,没有出现*m/s,有点遗憾,谁搞出来可以留言。
best wishes!

@qianjin1017

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@qianjin1017

qianjin1017 on 20 Aug 2020

按照

#只对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

太棒了,亲测有效

Copy link Report content

qianjin1017 commented on 20 Aug 2020

按照

#只对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

太棒了,亲测有效

@ijpq

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@ijpq

ijpq on 11 Sep 2020

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

work

Copy link Report content

ijpq commented on 11 Sep 2020

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

work

@forliuyifei

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@forliuyifei

forliuyifei on 25 Sep 2020

仿照上面的内容写了以下配置方案,操作系统是 win 10,代理用 SSR,端口 1080。
先设置了

git config --global http.https://github.com.proxy socks5h://127.0.0.1:1080

接着用

git config --global --get http.https://github.com.proxy

得到反馈

socks5h://127.0.0.1:1080

说明设置成功。
下面在用户文件夹的 .ssh 中建立 config 文件,内容为

ProxyCommand connect -S 127.0.0.1:1080 -a none %h %p

Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile "C:\Users\****\.ssh\id_rsa"
  TCPKeepAlive yes
  ServerAliveInterval 600
  IPQoS=throughput
  ServerAliveCountMax 120

Host ssh.github.com
  User git
  Port 443
  Hostname ssh.github.com
  IdentityFile "C:\Users\****\.ssh\id_rsa"
  TCPKeepAlive yes
  ServerAliveInterval 600
  IPQoS=throughput
  ServerAliveCountMax 120

注意****要换成用户自己的名称。
此配置单参考这里这里

显示:

socks5h://127.0.0.1:1080

可还是特别慢, 开了全局ssr, 端口也是1080

Copy link Report content

forliuyifei commented on 25 Sep 2020

仿照上面的内容写了以下配置方案,操作系统是 win 10,代理用 SSR,端口 1080。
先设置了

git config --global http.https://github.com.proxy socks5h://127.0.0.1:1080

接着用

git config --global --get http.https://github.com.proxy

得到反馈

socks5h://127.0.0.1:1080

说明设置成功。
下面在用户文件夹的 .ssh 中建立 config 文件,内容为

ProxyCommand connect -S 127.0.0.1:1080 -a none %h %p

Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile "C:\Users\****\.ssh\id_rsa"
  TCPKeepAlive yes
  ServerAliveInterval 600
  IPQoS=throughput
  ServerAliveCountMax 120

Host ssh.github.com
  User git
  Port 443
  Hostname ssh.github.com
  IdentityFile "C:\Users\****\.ssh\id_rsa"
  TCPKeepAlive yes
  ServerAliveInterval 600
  IPQoS=throughput
  ServerAliveCountMax 120

注意****要换成用户自己的名称。
此配置单参考这里这里

显示:

socks5h://127.0.0.1:1080

可还是特别慢, 开了全局ssr, 端口也是1080

@isjeffcom

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@isjeffcom

isjeffcom on 6 Oct 2020

https是没用的,无论复制的地址有没有SSL加密,改http.proxy就行了。顺便蹲一个办法,有没有办法只设置单次clone使用代理?

Copy link Report content

isjeffcom commented on 6 Oct 2020

https是没用的,无论复制的地址有没有SSL加密,改http.proxy就行了。顺便蹲一个办法,有没有办法只设置单次clone使用代理?

@forliuyifei

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@forliuyifei

forliuyifei on 22 Oct 2020

感觉没上网工具的日子会越来越难过😭

git 走 Clash 代理

image

设置 npm 强制走 Clash 代理

Copy link Report content

forliuyifei commented on 22 Oct 2020

感觉没上网工具的日子会越来越难过😭

git 走 Clash 代理

image

设置 npm 强制走 Clash 代理

@likemby

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@likemby

likemby on 12 Nov 2020

为什么设置成这样的代理就能加速啊,这是什么原理?

Copy link Report content

likemby commented on 12 Nov 2020

为什么设置成这样的代理就能加速啊,这是什么原理?

@aszswaz

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@aszswaz

aszswaz on 27 Nov 2020

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

Copy link Report content

aszswaz commented on 27 Nov 2020

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

@Valar103769

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@Valar103769

Valar103769 on 12 Jan

按照

#只对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

有用,谢谢

Copy link Report content

Valar103769 commented on 12 Jan

按照

#只对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

有用,谢谢

@Ron2014

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@Ron2014

Ron2014 on 17 Feb

在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代理了。

I have done with these in ~/.ssh/config

Host github.com
	HostName github.com
	User git
	# socks5 need: pacman -S mingw-w64-x86_64-connect mingw-w64-i686-connect
	ProxyCommand connect -S 127.0.0.1:2801 %h %p

Thanks you all..

$ git clone git@github.com:testerSunShine/12306.git
Cloning into '12306'...
remote: Enumerating objects: 2730, done.
fatal: index-pack failed(468/2730), 8.00 MiB | 3.82 MiB/s
client_loop: send disconnect: Broken pipe
fetch-pack: unexpected disconnect while reading sideband packet
Copy link Report content

Ron2014 commented on 17 Feb

在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代理了。

I have done with these in ~/.ssh/config

Host github.com
	HostName github.com
	User git
	# socks5 need: pacman -S mingw-w64-x86_64-connect mingw-w64-i686-connect
	ProxyCommand connect -S 127.0.0.1:2801 %h %p

Thanks you all..

$ git clone git@github.com:testerSunShine/12306.git
Cloning into '12306'...
remote: Enumerating objects: 2730, done.
fatal: index-pack failed(468/2730), 8.00 MiB | 3.82 MiB/s
client_loop: send disconnect: Broken pipe
fetch-pack: unexpected disconnect while reading sideband packet
@berxtjkl

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@berxtjkl

berxtjkl 21 days ago

Thanks, it helps.

Copy link Report content

berxtjkl commented 21 days ago

Thanks, it helps.

@Yaozhtj

This comment has been minimized.

Show comment
Hide comment
Copy link Report content
@Yaozhtj

Yaozhtj 7 days ago

is slower 😫

Copy link Report content

Yaozhtj commented 7 days ago

is slower 😫

@Dkngit