需求
克隆的仓库git clone https://github.com/xxxx
时,让其默认走git
协议拉取仓库(git clone git@github.com:xxxx
)
方式一
[url "git@github.com:"]
insteadOf = https://github.com/
方式二
git config --global url."https://github.com/".insteadOf "git@github.com:"
代理 (http/https)
代理 方式一 推荐
git clone -c http.proxy="127.0.0.1:40001" https://github.com/pingcap/tidb.git
127.0.0.1:40001 为你的代理端口
代理 方式二
终端输入
export http_proxy=http://127.0.0.1:40001
export https_proxy=$http_proxy
127.0.0.1:40001 为你的代理端口
最后执行
git clone https://github.com/pingcap/tidb.git
注意: 终端关闭后,代理结束
代理 (ssh协议配置代理)
代理 (ssh协议配置代理) 方式一
编辑文件
vim ~/.ssh/config
加入
Host github.com
User git
Hostname github.com
ProxyCommand nc -v -x 127.0.0.1:40001 %h %p
127.0.0.1:40001 为你的代理端口
-X
代理协议: 4是socks4协议 ,5是socks5协议
-x
代理服务器和端口[代理服务器:端口]
最后执行 克隆
git clone git@github.com:pingcap/tidb.git