0
点赞
收藏
分享

微信扫一扫

terminal git 设置代理,速度飙升

木匠0819 2022-06-30 阅读 140

参考链接: ​​https://gist.github.com/fearblackcat/850c6e027d5a03017c44daaa6a7ffc30​​

很多时候我们在使用 github 的时候会出现下载很慢的情况。
如果你有代理,可以直接设置代理,来获取更快下载和上传资源的速度。

给 git 设置 SOCKS5 代理:

使用 ​​https​​ 的时候,就是使用 ​​https​​ 协议复制仓库的时候

如: ​​https://github.com/KyleBing/TouchbarBBT.git​​

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

也可以直接修改用户主目录下的 ​​.gitconfig​​ 文件

[http]
proxy = socks5://127.0.0.1:1080
[https]
proxy = socks5://127.0.0.1:1080

在使用 ​​git​​ 开头的路径时,也就是在使用 ​​ssh​​ 通道时

如: ​​git@github.com​​:KyleBing/TouchbarBBT.git

打开用户主目录下的 ​​.ssh/config​​ 文件,添加以下内容

ProxyCommand nc -x localhost:1080 %h %p

效果,速度是真快

之前的速度:

terminal git 设置代理,速度飙升_github

之后的速度:

terminal git 设置代理,速度飙升_主目录_02

言外

terminal 中设置临时代理

直接执行

export ALL_PROXY=socks5://127.0.0.1:1080

或者在用户主目录下的 ​​.bash_profile​​​ 添加别名,这样以后在使用的时候就可以直接输入 ​​proxy​​了

alias proxy="export ALL_PROXY=socks5://127.0.0.1:1080"


举报

相关推荐

0 条评论