抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

当在克隆或从远程仓库获取数据时,很可能因为网络状况不佳遇到很慢甚至超时的情况,那么此时您可能需要配置 Git 的代理。

第一种:使用镜像站

最常见 GitHub 镜像地址:
https://gitclone.com/
https://hub.fastgit.org/
https://github.com.cnpmjs.org/
访问上面的镜像网站,网站的内容跟 GitHub 是完整同步的镜像,然后在这个网站里面进行下载克隆等操作。
举个栗子: git clone https://github.com/microsoft/vscode.git
替换为 :git clone https://gitclone.com/github.com/microsoft/vscode

第二种 设置git参数

1
2
git config --global url."https://gitclone.com/".insteadOf https://
git clone https://github.com/microsoft/vscode.git

第三种 使用cgit工具

下载链接:https://github.com/git-cloner/gitcache/releases

1
cgit clone https://github.com/microsoft/vscode.git

第四种 使用本地代理

1
2
3
4
5
6
7
8
# 设置代理
git config --global http.proxy <protocol>://<host>:<port>
*--glboal 选项指的是修改 Git 的全局配置文件 ~/.gitconfig(而非各个 Git 仓库里的配置文件 .git/config)。
*<protocol> 指的是代理协议,如 http,https,socks5 等。
*<host> 为代理主机,如使用本地代理主机 127.0.0.1 或 localhost 等。
*<port> 则为代理端口号,如 clash 使用的 7890 或 7891 等。
# 取消代理
git config --global --unset http.proxy

评论