在国内使用 Git 时,由于网络限制,直接从官方源下载安装包或克隆仓库往往速度缓慢甚至失败。本文将提供一套完整的国内镜像解决方案,涵盖从 Git 软件安装到日常使用加速的全流程,帮助开发者无需翻墙即可高效完成 Git 相关操作。
一、国内镜像源安装 Git
1.1 选择国内镜像源下载安装包
国内多所高校和企业提供了 Git 安装包的镜像服务,下载速度远超国际源:
- 中科大镜像源:https://mirrors.ustc.edu.cn/git/
- 清华大学镜像源:https://mirrors.tuna.tsinghua.edu.cn/git/
- 阿里云镜像源:https://registry.npmmirror.com/binary.html?path=git-for-windows/
- 码云 (Gitee) 镜像:https://gitee.com/mirrors/git-for-windows
推荐优先使用阿里云或中科大镜像,更新频率高且下载稳定。
1.2 各系统安装步骤
Windows 系统安装:
- 从上述镜像站下载最新版 Git for Windows(如 Git-2.42.0.2-64-bit.exe)
- 双击安装包,建议修改安装路径到非系统盘(如 D:\Environment\Git)
- 安装时勾选"Add Git to PATH"选项以便全局使用
- 完成安装后验证:
git --version
Linux 系统安装(以 Ubuntu 为例):
# 临时替换为清华源
sudo sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
# 更新源并安装 Git
sudo apt update && sudo apt install git
安装完成后验证版本:git --version


