git设置代理

  |  

centos 安装 git
sudo yum install -y git

设置代理:

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

查看代理:

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

取消代理:

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

出现下图错误,是因为你开启了 git 代理,代理连接不上 所以你可以取消代理
在这里插入图片描述

设置代理还可以通过修改配置文件形式
在用户目录下的.gitconfig 文件(如果不存在则创建)中写入
[http]
proxy = https://127.0.0.1:1080 //代理配置
[credential]
helper = store //凭证配置【这个配置表明将会在第一次使用用户密码之后记住该密码,即下次不用在输入】
如果你的凭证位置没有指定,则去用户目录下查看,发现多了一个.git_credentials 文件,打开文件可以看到里面以明文存放你的用户名和密码
[user]
name = robot //用户配置
email = robot@mland.club
[push]
default = simple

文章目录