最近 git clone 一个项目真的是太慢了,每秒 7kb。。。电脑上也刚好有 ti 子,试试能不能让 git 工具走代理的方式,能不能更快些,实测效果好了很多,设置如下

设置使用代理

将你的proxy server地址代替以下的127.0.0.1

http类型代理

git config –global http.proxy http://127.0.0.1:1080 (这条即可) git config –global https.proxy https://127.0.0.1:1080

socks5类型代理

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 –get http.proxy git config –global –get https.proxy

取消设置代理

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

仅对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

设置使用需账户密码验证的代理

http类型代理 git config –global http.proxy http://username:passwd@127.0.0.1:1080 socks5类型代理 git config –global http.proxy socks5://username:passwd@127.0.0.1:1080

或者直接修改文件

mac 一般在这个路径下 /Users/电脑的用户名/.gitconfig,修改后如下内容

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
[user]
	name = 
	email = 
[core]
	autocrlf =
	excludesfile = 
[difftool "sourcetree"]
	cmd = 
	path = 
[mergetool "sourcetree"]
	cmd = 
	trustExitCode = true
[commit]
	template = 
[credential]
	helper = store
[http]
	proxy = socks5://127.0.0.1:1080 
[https]
	proxy = socks5://127.0.0.1:1080 

转载链接: git使用代理加速