网站首页 > 精选文章 正文
1. 问题描述
但凡要去国外搞点东西回来,这网络就慢的不行。还要有各种加速方法,让我们可以把东西顺利的搞回来。当然,我们这里并不是要介绍这些方法,而是要介绍如何使用,并且每种工具使用这些方法的方式都是不同的(技术文章的断句事件非常痛苦的事情)。
在到 GitHub 拉取那些纯净无害的代码时,我们就会遇到这种网络问题。这时候我们就需要配置 Git 来使用网络加速服务,以提高代码拉取速度。
该笔记将记录:在 Gti 中,如何使用网络加速服务,以提高代码拉取速度,以及相关问题处理。
2. 解决方案
2.1. 持久配置
修改配置文件:
# 配置当前仓库,以及取消配置
git config http.proxy 'socks5://127.0.0.1:7070' # 通过袜子协议:-)
git config --unset http.proxy
# 全局配置,以及取消配置
git config --global http.proxy 'http://127.0.0.1:8123'
git config --global --unset http.proxy
注意事项:
1)选项 http.proxy 适用于 HTTP 与 HTTPS 协议;
2)对于那些调用 Git 命令来拉取代码的程序,使用 全局配置 方式基本是唯一的选择;
2.2. 临时配置
仅对本次克隆有效:
# 方法一、命令行选项
git clone https://github.com/xxxxx --config 'http.proxy=socks5://127.0.0.1:1234'
# 方法二、环境变量
ALL_PROXY='socks5://127.0.0.1:8888' git clone https://github.com/some/one.git
2.3. 特殊场景
仅针对某个地址使用网络加速(并且禁用 SSL 验证):
git config --global http.https://domain.com.proxy "http://proxy.example.com:port"
git config --global http.https://domain.com.sslVerify false
3. 相关链接
关于网络加速的更多配置,参考 Configure Git to use a proxy(https://gist.github.com/evantoli/f8c23a37eb3558ab8765%20) 页面。
4. 参考文献
Using a socks proxy with git for the http transport(https://stackoverflow.com/questions/15227130/using-a-socks-proxy-with-git-for-the-http-transport)
- 上一篇: git拉代码每次都要输入账号密码?
- 下一篇: git pull 之后本地代码被覆盖 解决方案
猜你喜欢
- 2024-12-17 开放网络环境下,SVN/GIT代码服务器安全共享思路
- 2024-12-17 Git提交代码时忽略不必要的文件或文件夹
- 2024-12-17 终极Git指南:轻松掌握快速提交、分支管理与代码保护技巧!
- 2024-12-17 使用 Git 时,如何巧妙地避免冲突(merge conflict)?
- 2024-12-17 git pull 之后本地代码被覆盖 解决方案
- 2024-12-17 git拉代码每次都要输入账号密码?
- 2024-12-17 Git安全性:如何确保代码安全性
- 2024-12-17 git提交被拒绝 non-fast-forward 与 pull 强制覆盖本地的代码
- 2024-12-17 零基础走向“人工智能与数据分析”系列:数据与代码保存Git
- 2024-12-17 git合并代码分支的方法
- 最近发表
- 标签列表
-
- 向日葵无法连接服务器 (32)
- git.exe (33)
- vscode更新 (34)
- dev c (33)
- git ignore命令 (32)
- gitlab提交代码步骤 (37)
- java update (36)
- vue debug (34)
- vue blur (32)
- vscode导入vue项目 (33)
- vue chart (32)
- vue cms (32)
- 大雅数据库 (34)
- 技术迭代 (37)
- 同一局域网 (33)
- github拒绝连接 (33)
- vscode php插件 (32)
- vue注释快捷键 (32)
- linux ssr (33)
- 微端服务器 (35)
- 导航猫 (32)
- 获取当前时间年月日 (33)
- stp软件 (33)
- http下载文件 (33)
- linux bt下载 (33)