Git 提速方法总结

修改 Git 方法

https://www.cnblogs.com/dakewei/archive/2017/08/31/7461069.html

https://www.jianshu.com/p/aac268316639

https://www.zhihu.com/question/27159393/answer/141047266
此方法亲测最有效!

  1. 安装 Git

brew install git

  1. 设置 socks5 代理

方式一: 设置全局使用socks5代理,并且使用 http 传输(提速真的很明显),
只能使用https://github.com/xxx/xxx.git

# 代理设置
# 端口号可以自己查看 ssr 的设置
git config --global http.proxy 'socks5://127.0.0.1:1086'
git config --global https.proxy 'socks5://127.0.0.1:1086'

# 推荐,只代理 github,不影响国内 repo
git config --global http.https://github.com.proxy https://127.0.0.1:1086
git config --global https.https://github.com.proxy https://127.0.0.1:1086


# 取消代理设置
git config --global --unset http.proxy
git config --global --unset http.https

方式二:
~/.gitconfig文件中添加下面的文本

[http]
	proxy = socks5://127.0.0.1:1080
[https]
	proxy = socks5://127.0.0.1:1080
  1. 开始 clone
    如果觉得仓库太大,可以在 git clone 中加入参数 --depth=1,只拉取最近的一个 revision。

  2. 如果后面想看历史的版本,使用 git fetch 即可。
    git fetch --unshallow

中转 Git 方法

通过 gitee.com or coding.net or gitlab.com 进行中转下载.

修改 DNS 方法

通过 ipaddress.com 去查真实 ip 然后更改 hosts 的方法,发现这是个坑。
https://blog.csdn.net/u012413167/article/details/81299416

将 DNS 改为 8.8.8.8

查询未被污染的ip也可以 nslookup -vc github.com 8.8.8.8

修改 hosts 方法

https://www.jianshu.com/p/74f561d7293d

此方法用处不大.
/etc/hosts文件中手动或者用 vim 添加

151.101.76.249 github.global.ssl.fastly.net
192.30.253.112 github.com

# 刷新缓存
sudo dscacheutil -flushcache
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值