Git设置代理

设置

可以是直接使用命令进行设置,也可以编辑~/.gitconfig文件

1、使用命令

http代理:

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

socks5代理:

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

2、编辑文件~/.gitconfig

在文件添加:

[http]
proxy = socks5://127.0.0.1:10800

[https]
proxy = socks5://127.0.0.1:10800

查看

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

取消

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

针对docker容器的代理配置:

在创建(run)容器的时候,加上 –net=host 这个选项,就可以实现容器内外共享网络,然后再在容器内部配置git,就可以实现容器内代理了

参考:
https://www.jianshu.com/p/b902b489ecc8
https://www.cnblogs.com/yongy1030/p/11699086.html
https://baijiahao.baidu.com/s?id=1603409484949165821&wfr=spider&for=pc&tdsourcetag=s_pctim_aiomsg&qq-pf-to=pcqq.c2c


已发布

分类

来自

标签:

评论

《“Git设置代理”》 有 1 条评论

  1. 匿名

    由于 git 在 push 的时候使用的其实是 curl
    因此我们只需要对 curl 设置 socks 代理即可
    export all_proxy=socks5://127.0.0.1:1080

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注