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

相关推荐
猫头虎2 小时前
GoLand 2025.3 最新变化:值得更新吗?
ide·windows·macos·pycharm·编辑器·intellij-idea·idea
逛逛GitHub3 小时前
一周狂揽 4500 的 Star!这个 AI 流程图开源项目火了。
github
这儿有一堆花4 小时前
软件世界的契约:理解开源协议的逻辑与边界
github·开源协议
CoderJia程序员甲4 小时前
GitHub 热榜项目 - 日榜(2025-12-18)
ai·开源·大模型·github·ai教程
_可乐无糖6 小时前
内网穿透工具使用指南:ngrok 和 cpolar
安全·macos·云计算
不爱吃糖的程序媛7 小时前
鸿蒙PC命令行开发 macOS 上解决 pkg-config 命令未安装的问题
macos·华为·harmonyos
Hy行者勇哥7 小时前
MobaXterm 高效运维实战:从入门到进阶的 Linux 运维 “瑞士军刀” 用法
linux·运维·github
淘气淘的宝宝8 小时前
MAC intel 迁移至M4后brew及iterm2配置
macos
不爱吃糖的程序媛8 小时前
解决鸿蒙PC命令行编译 macOS 上 cp 命令参数冲突问题
macos·harmonyos·策略模式
Bruce_Liuxiaowei8 小时前
Mac_Linux 查询网站IP地址:4个核心命令详解
linux·tcp/ip·macos