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文本编辑器

相关推荐
John Song25 分钟前
git多个账号管理
git·github
开开心心loky2 小时前
[iOS] GCD - 线程与队列
macos·ios·objective-c·cocoa
破烂pan2 小时前
github精选Agent学习repo
llm·github·agent
XU磊2603 小时前
Git 实现github仓库管理-删除指定目录下的所有文件并保留目录结构
git·github
冷冷的菜哥4 小时前
21款m1 max升级到macOS 14——Sonoma
macos·苹果·sonoma·macos系统升级
laocaibulao4 小时前
mac电脑composer命令如何指定PHP版本
macos·php·composer
00后程序员张4 小时前
iOS 上架费用全解析 开发者账号、App 审核、工具使用与开心上架(Appuploader)免 Mac 成本优化指南
android·macos·ios·小程序·uni-app·cocoa·iphone
fukai77229 小时前
OmniFocus:专为 macOS 与 iOS 打造的专业级任务管理利器
macos·ios
逛逛GitHub9 小时前
1 天狂揽 4000 多 Star 的 AI 舆情分析开源神器。
github
卡洛斯(编程版10 小时前
大仓库推到GitHub大踩坑-Git LFS从安装到使用
git·github