MAC 如何解决GitHub下载速度慢的问题

说在前面

解决github下载速度慢的方法很多,本文主要介绍通过Git镜像的方式解决下载慢的问题。 主要步骤有:1、找到gitconfig文件, 2、通过git命令查看当前生效的config 配置 3、使用git config命令编辑并添加国内镜像源

1、gitconfig 文件在哪里?

Git 一共有3个配置文件:

  1. 仓库级的配置文件:在仓库的 .git/.gitconfig,该配置文件只对所在的仓库有效。
  2. 全局配置文件:Mac 系统在 ~/.gitconfig,Windows 系统在 C:\Users<用户名>.gitconfig。
  3. 系统级的配置文件:在 Git 的安装目录下(Mac 系统下安装目录在 /usr/local/git)的 etc 文件夹中的 gitconfig。

2、git config 操作的相关命令

bash 复制代码
# 查看配置信息
# --local:仓库级,--global:全局级,--system:系统级
$ git config <--local | --global | --system> -l

# 查看当前生效的配置信息
$ git config -l

# 编辑配置文件
# --local:仓库级,--global:全局级,--system:系统级
$ git config <--local | --global | --system> -e

# 添加配置项
# --local:仓库级,--global:全局级,--system:系统级
$ git config <--local | --global | --system> --add <name> <value>

3、Git镜像源的选择

由于Git是分布式的版本控制系统,可以从多个镜像源进行Git操作。这里提供一些Git镜像,我们可以将就近的Git镜像加入.git/config文件中:

1、中科大镜像源

url "https://mirrors.ustc.edu.cn/git/"

insteadOf = https://github.com/

insteadOf = https://gitlab.com/

insteadOf = https://bitbucket.com/

2、清华大学镜像源

url "https://mirrors.tuna.tsinghua.edu.cn/git/"

insteadOf = https://github.com/

insteadOf = https://gitlab.com/

insteadOf = https://bitbucket.com/

3、阿里云镜像源

url "https://code.aliyun.com/"

insteadOf = https://github.com/

insteadOf = https://gitlab.com/

insteadOf = https://bitbucket.com/

参考:

如何解决GitHub下载速度慢的问题

Mac Git 配置全局gitconfig

mac上怎么看隐藏文件(显示Mac隐藏文件的三种方式

Linux 学习笔记 - vim文本编辑器

相关推荐
2401_8734794043 分钟前
运营活动被薅羊毛怎么防?用IP查询+设备指纹联动封堵漏洞
java·网络·tcp/ip·github
哆哆啦004 小时前
使用 Obsidian + GitHub Actions + GitHub Pages 搭建内容发布流
数据库·笔记·github·obsidian
秋雨梧桐叶落莳6 小时前
iOS——ZARA仿写项目
学习·macos·ios·objective-c·cocoa
厚皮龙7 小时前
使用 SSH 密钥上传 GitHub 仓库流程
运维·ssh·github
2601_955781988 小时前
OpenClaw快速接入Ollama本地模型教程
github·open claw安装·open claw部署
Dvesiz9 小时前
【ClaudeCode平替(免费)】OpenCode 完整安装与 VSCode 使用指南
ide·vscode·编辑器·github·ai编程·claude·visual studio code
2501_9160074712 小时前
Xcode支持的编程语言、主要功能及使用指南
ide·vscode·macos·ios·个人开发·xcode·敏捷流程
Hommy8813 小时前
【剪映小助手】音频信息生成接口
开源·github·剪映小助手
分***813 小时前
MacOS苹果电脑下怎么打开md格式文件?超好用的macOS原生Markdown编辑器MiaoYan分享
macos·编辑器·macdown编辑器
qq_4572107113 小时前
Mac 上 Claude Code 完整安装使用指南(跳过登录注册)
macos