git设置代理加速

实在没办法啊,这个github太慢了我受够你了

参考:https://baijiahao.baidu.com/s?id=1603409484949165821&wfr=spider&for=pc

命令设置

# http代理
git config --global https.proxy http://192.168.124.169:1081
git config --global http.proxy http://192.168.124.169:1081
# socks5代理(没有测试)
git config --global http.proxy 'socks5://127.0.0.1:10800'
git config --global https.proxy 'socks5://127.0.0.1:10800'

查看config配置

[root@logstash scripts]# git config -l
https.proxy=http://192.168.124.169:1081
http.proxy=http://192.168.124.169:1081

取消代理配置

[root@logstash scripts]# git config --global --unset http.proxy
[root@logstash scripts]# git config --global --unset https.proxy
[root@logstash scripts]# git config -l

编辑文本设置

# socks5代理未测试
[root@logstash tmp]# cat ~/.gitconfig 
[https]
proxy=http://192.168.124.169:1081
[http]
proxy=http://192.168.124.169:1081

git配置级别

根据此篇文章描述,了解到git配置分local,global,system三个级别配置

local是对当前仓库有效的,对应的配置文件在.git/config

[root@logstash docker-repos]# git config --local -l
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://github.com/uscwifi/docker-repos.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
[root@logstash docker-repos]# cat .git/config 
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = https://github.com/uscwifi/docker-repos.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master

global是对当前用户有效的,对应配置文件在~/.gitconfig

[root@logstash docker-repos]# git config --global -l
https.proxy=http://192.168.124.169:1081
http.proxy=http://192.168.124.169:1081
[root@logstash docker-repos]# cat ~/.gitconfig 
[https]
proxy=http://192.168.124.169:1081
[http]
proxy=http://192.168.124.169:1081

system对全体用户生效,配置文件在/etc/gitconfig

[root@logstash docker-repos]# git config --system -l
fatal: unable to read config file '/etc/gitconfig': No such file or directory