Xget 各平台使用指南
详细说明Xget在GitHub、GitLab、Docker Hub、PyPI、Hugging Face等主流平台的具体使用方法和URL转换规则。本文提供各平台的加速示例、wget/curl命令模板以及常见问题解决方案,帮助开发者快速上手并充分利用Xget的加速能力
概述
本文档详细介绍了如何在各个支持平台上使用 Xget 进行加速。包括代码托管、包管理、容器镜像、AI 模型等各种场景的具体使用方法。
代码托管平台
GitHub
基本使用
下载文件
# 原始 URL
https://github.com/microsoft/vscode/archive/refs/heads/main.zip
# 加速 URL
wget https://xget.xi-xu.me/gh/microsoft/vscode/archive/refs/heads/main.zip
下载 Release
# 下载特定版本的 Release
wget https://xget.xi-xu.me/gh/nodejs/node/releases/download/v20.10.0/node-v20.10.0-x64.msi
Git 操作
Clone 仓库
# 完整克隆
git clone https://xget.xi-xu.me/gh/microsoft/vscode.git
# 浅克隆(只克隆最新提交)
git clone --depth 1 https://xget.xi-xu.me/gh/microsoft/vscode.git
# 克隆特定分支
git clone -b main https://xget.xi-xu.me/gh/microsoft/vscode.git
Pull 和 Fetch
# 拉取最新代码
git pull origin main
# 获取远程更新
git fetch origin
Push 操作
# 推送到远程仓库
git push origin main
# 推送所有分支
git push --all origin
Submodule 操作
# 克隆包含子模块的仓库
git clone --recursive https://xget.xi-xu.me/gh/microsoft/vscode.git
# 更新子模块
git submodule update --init --recursive
高级用法
Git LFS 支持
# 克隆包含 LFS 文件的仓库
GIT_LFS_SKIP_SMUDGE=1 git clone https://xget.xi-xu.me/gh/microsoft/vscode.git
cd vscode
git lfs pull
配置 Git 使用 Xget
# 全局配置
git config --global url."https://xget.xi-xu.me/gh/".insteadOf "https://github.com/"
# 仅对特定仓库配置
cd your-repo
git config url."https://xget.xi-xu.me/gh/".insteadOf "https://github.com/"
GitHub Gist
下载 Gist
# 下载 Gist 文件
wget https://xget.xi-xu.me/gist/xixu-me/e2ea9db6b1f143892495f796fef18631/raw/3b8807172ee492d0da3a7e370b0fb88fc97b53e6/Free-ChatGPT-Paid-Plan.md
克隆 Gist
# 克隆 Gist 仓库
git clone https://xget.xi-xu.me/gist/xixu-me/e2ea9db6b1f143892495f796fef18631.git
GitLab
下载文件
# 下载压缩包
wget https://xget.xi-xu.me/gl/gitlab-org/gitlab/-/archive/master/gitlab-master.zip
Git 操作
# Clone 仓库
git clone https://xget.xi-xu.me/gl/gitlab-org/gitlab.git
# Pull 更新
git pull origin main
Gitea
下载文件
# 下载压缩包
wget https://xget.xi-xu.me/gitea/gitea/gitea/archive/master.zip
Git 操作
# Clone 仓库
git clone https://xget.xi-xu.me/gitea/gitea/gitea.git
Codeberg
下载文件
# 下载压缩包
wget https://xget.xi-xu.me/codeberg/forgejo/forgejo/archive/forgejo.zip
Git 操作
# Clone 仓库
git clone https://xget.xi-xu.me/codeberg/forgejo/forgejo.git
SourceForge
下载文件
# 下载软件
wget https://xget.xi-xu.me/sf/projects/sevenzip/files/7-Zip/23.01/7z2301-x64.exe/download
使用 aria2c 多线程下载
aria2c -x 16 -s 16 https://xget.xi-xu.me/sf/projects/sevenzip/files/7-Zip/23.01/7z2301-x64.exe/download
AOSP (Android 开源项目)
Git 操作
# Clone AOSP 项目
git clone https://xget.xi-xu.me/aosp/platform/frameworks/base
# Clone 设备树
git clone https://xget.xi-xu.me/aosp/device/google/pixel
使用 repo 工具
# 配置 repo 使用 Xget
export REPO_URL="https://xget.xi-xu.me/aosp/tools/repo"
# 初始化仓库
repo init -u https://xget.xi-xu.me/aosp/platform/manifest
# 同步代码
repo sync
AI/ML 平台
Hugging Face
下载模型文件
# 下载单个模型文件
wget https://xget.xi-xu.me/hf/microsoft/DialoGPT-medium/resolve/main/pytorch_model.bin
# 下载配置文件
wget https://xget.xi-xu.me/hf/microsoft/DialoGPT-medium/resolve/main/config.json
下载完整模型
# 使用 huggingface-cli
pip install huggingface-hub
# 配置使用 Xget
export HF_ENDPOINT="https://xget.xi-xu.me/hf"
# 下载模型
huggingface-cli download microsoft/DialoGPT-medium
下载数据集
# 下载数据集文件
wget https://xget.xi-xu.me/hf/datasets/rajpurkar/squad/resolve/main/plain_text/train-00000-of-00001.parquet
# 使用 datasets 库
pip install datasets
# 配置使用 Xget
export HF_ENDPOINT="https://xget.xi-xu.me/hf"
# 下载数据集
python -c "from datasets import load_dataset; ds = load_dataset('rajpurkar/squad')"
Python 代码示例
from huggingface_hub import snapshot_download
# 配置使用 Xget
import os
os.environ['HF_ENDPOINT'] = 'https://xget.xi-xu.me/hf'
# 下载模型
model_path = snapshot_download(repo_id="microsoft/DialoGPT-medium")
Civitai
下载模型
# 下载模型文件
wget https://xget.xi-xu.me/civitai/api/download/models/128713 -O model.safetensors
使用 API
# 获取模型信息
curl https://xget.xi-xu.me/civitai/api/v1/models/7240
# 获取模型版本信息
curl https://xget.xi-xu.me/civitai/api/v1/model-versions/128713
Python 代码示例
import requests
# 配置使用 Xget
base_url = "https://xget.xi-xu.me/civitai/api"
# 获取模型信息
response = requests.get(f"{base_url}/v1/models/7240")
model_info = response.json()
# 下载模型
download_url = model_info['downloadUrl']
response = requests.get(download_url)
with open('model.safetensors', 'wb') as f:
f.write(response.content)
包管理平台
npm
配置 npm 使用 Xget
# 设置 npm 注册表
npm config set registry https://xget.xi-xu.me/npm
# 验证配置
npm config get registry
安装包
# 安装包
npm install react
# 安装特定版本
npm install react@18.2.0
# 全局安装
npm install -g typescript
下载包文件
# 直接下载包文件
wget https://xget.xi-xu.me/npm/react/-/react-18.2.0.tgz
使用 .npmrc
在项目根目录创建 .npmrc 文件:
registry=https://xget.xi-xu.me/npm
PyPI
配置 pip 使用 Xget
# 使用 Xget 作为索引 URL
pip install --index-url https://xget.xi-xu.me/pypi requests
# 额外索引 URL
pip install --extra-index-url https://xget.xi-xu.me/pypi requests
使用 pip.conf
创建或编辑 ~/.pip/pip.conf:
[global]
index-url = https://xget.xi-xu.me/pypi
下载包文件
# 下载源码包
wget https://xget.xi-xu.me/pypi/packages/source/r/requests/requests-2.31.0.tar.gz
# 下载 Wheel 文件
wget https://xget.xi-xu.me/pypi/packages/py3/n/numpy/numpy-1.26.2-cp312-cp312-win_amd64.whl
使用 pip download
# 下载包及其依赖
pip download --index-url https://xget.xi-xu.me/pypi requests
# 下载到指定目录
pip download --index-url https://xget.xi-xu.me/pypi -d ./packages requests
conda
配置 conda 使用 Xget
# 添加 Xget 作为频道
conda config --add channels https://xget.xi-xu.me/conda/pkgs/main
# 添加社区频道
conda config --add channels https://xget.xi-xu.me/conda/community/conda-forge
# 验证配置
conda config --show channels
安装包
# 安装包
conda install python=3.11
# 从特定频道安装
conda install -c https://xget.xi-xu.me/conda/community/conda-forge pytorch
下载包文件
# 下载包文件
wget https://xget.xi-xu.me/conda/pkgs/main/win-64/python-3.11.0-h955f1ad_0.conda
使用 .condarc
创建或编辑 ~/.condarc:
channels:
- https://xget.xi-xu.me/conda/pkgs/main
- https://xget.xi-xu.me/conda/community/conda-forge
- defaults
Maven
配置 Maven 使用 Xget
编辑 ~/.m2/settings.xml:
<settings>
<mirrors>
<mirror>
<id>xget-maven</id>
<mirrorOf>central</mirrorOf>
<name>Xget Maven Mirror</name>
<url>https://xget.xi-xu.me/maven2</url>
</mirror>
</mirrors>
</settings>
下载依赖
# 使用 Maven 下载依赖
mvn dependency:resolve
# 下载源码
mvn dependency:sources
下载 JAR 文件
# 直接下载 JAR 文件
wget https://xget.xi-xu.me/maven2/org/springframework/spring-core/6.1.1/spring-core-6.1.1.jar
Gradle
配置 Gradle 使用 Xget
编辑 build.gradle:
repositories {
maven { url 'https://xget.xi-xu.me/maven2' }
mavenCentral()
}
或编辑 settings.gradle:
dependencyResolutionManagement {
repositories {
maven { url 'https://xget.xi-xu.me/maven2' }
mavenCentral()
}
}
下载依赖
# 下载依赖
./gradlew dependencies
# 下载源码
./gradlew downloadSources
下载插件
# 下载 Gradle 插件
wget https://xget.xi-xu.me/gradle/m2/com/github/ben-manes/gradle-caches-plugin/0.9.0/gradle-caches-plugin-0.9.0.pom
Homebrew
配置 Homebrew 使用 Xget
# 设置 Homebrew 使用 Xget
export HOMEBREW_BREW_GIT_REMOTE="https://xget.xi-xu.me/homebrew/brew"
export HOMEBREW_CORE_GIT_REMOTE="https://xget.xi-xu.me/homebrew/homebrew-core"
# 更新 Homebrew
brew update
安装软件
# 安装软件
brew install python
# 安装 Cask
brew install --cask visual-studio-code
RubyGems
配置 gem 使用 Xget
# 设置 gem 源
gem sources --add https://xget.xi-xu.me/rubygems
gem sources --remove https://rubygems.org/
# 验证配置
gem sources -l
安装 gem
# 安装 gem
gem install rails
# 安装特定版本
gem install rails -v 7.1.2
下载 gem 文件
# 下载 gem 文件
wget https://xget.xi-xu.me/rubygems/gems/rails-7.1.2.gem
CRAN ®
配置 R 使用 Xget
在 R 中执行:
# 设置 CRAN 镜像
options(repos = c(CRAN = "https://xget.xi-xu.me/cran"))
# 验证配置
options()$repos
安装包
# 安装包
install.packages("ggplot2")
# 安装特定版本
install.packages("https://xget.xi-xu.me/cran/src/contrib/Archive/ggplot2/ggplot2_3.4.4.tar.gz")
下载包文件
# 下载源码包
wget https://xget.xi-xu.me/cran/src/contrib/ggplot2_3.4.4.tar.gz
CPAN (Perl)
配置 CPAN 使用 Xget
# 设置 CPAN 镜像
cpanm --mirror https://xget.xi-xu.me/cpan --mirror-only Module::Name
安装模块
# 安装模块
cpanm Plack
# 从 URL 安装
cpanm https://xget.xi-xu.me/cpan/authors/id/M/MI/MIYAGAWA/Plack-1.050.tar.gz
下载模块文件
# 下载模块文件
wget https://xget.xi-xu.me/cpan/authors/id/M/MI/MIYAGAWA/Plack-1.050.tar.gz
CTAN (TeX/LaTeX)
下载 TeX 包
# 下载 TeX 包
wget https://xget.xi-xu.me/ctan/tex-archive/macros/latex/contrib/beamer.zip
# 使用 tlmgr 配置
tlmgr option repository https://xget.xi-xu.me/ctan/tex-archive/tlcontrib
Go 模块
配置 Go 使用 Xget
# 设置 Go 代理
export GOPROXY=https://xget.xi-xu.me/golang
# 验证配置
go env GOPROXY
下载模块
# 下载模块
go mod download github.com/golang/go@v1.21.5
# 获取依赖
go get github.com/golang/go@v1.21.5
下载模块文件
# 下载模块文件
wget https://xget.xi-xu.me/golang/github.com/golang/go/@v/v1.21.5.zip
NuGet (.NET)
配置 NuGet 使用 Xget
编辑 NuGet.Config:
<configuration>
<packageSources>
<add key="xget" value="https://xget.xi-xu.me/nuget" protocolVersion="3" />
</packageSources>
</configuration>
安装包
# 使用 dotnet 安装包
dotnet add package Newtonsoft.Json --source https://xget.xi-xu.me/nuget
# 使用 NuGet CLI
nuget install Newtonsoft.Json -Source https://xget.xi-xu.me/nuget
下载包文件
# 下载 nupkg 文件
wget https://xget.xi-xu.me/nuget/v3-flatcontainer/newtonsoft.json/13.0.3/newtonsoft.json.13.0.3.nupkg
Rust Crates
配置 Cargo 使用 Xget
编辑 ~/.cargo/config.toml:
[source.xget]
registry = "https://xget.xi-xu.me/crates"
[registries.xget]
index = "https://xget.xi-xu.me/crates"
[crates-io]
replace-with = "xget"
安装 crate
# 安装 crate
cargo install ripgrep
# 添加依赖
cargo add serde
下载 crate 文件
# 下载 crate 文件
wget https://xget.xi-xu.me/crates/api/v1/crates/serde/1.0.195/download
Packagist (PHP)
配置 Composer 使用 Xget
编辑 composer.json:
{
"repositories": [
{
"type": "composer",
"url": "https://xget.xi-xu.me/packagist"
}
]
}
或编辑 ~/.composer/config.json:
{
"repositories": {
"packagist.org": {
"type": "composer",
"url": "https://xget.xi-xu.me/packagist"
}
}
}
安装包
# 安装包
composer require laravel/framework
# 更新依赖
composer update
系统包管理平台
Debian/Ubuntu
配置 apt 使用 Xget
编辑 /etc/apt/sources.list:
deb https://xget.xi-xu.me/debian bookworm main contrib non-free
或编辑 /etc/apt/sources.list.d/xget.list:
deb https://xget.xi-xu.me/ubuntu jammy main restricted universe multiverse
更新和安装
# 更新包列表
sudo apt update
# 安装包
sudo apt install nginx
# 下载包文件
apt-get download nginx
Fedora
配置 dnf 使用 Xget
编辑 /etc/yum.repos.d/xget.repo:
[xget]
name=Xget Fedora Mirror
baseurl=https://xget.xi-xu.me/fedora/linux/releases/$releasever/Everything/$basearch/os/
enabled=1
gpgcheck=0
更新和安装
# 更新包列表
sudo dnf makecache
# 安装包
sudo dnf install nginx
# 下载包文件
sudo dnf download nginx
Rocky Linux
配置 dnf 使用 Xget
编辑 /etc/yum.repos.d/xget.repo:
[xget-baseos]
name=Xget Rocky Linux BaseOS
baseurl=https://xget.xi-xu.me/rocky/$releasever/BaseOS/$basearch/os/
enabled=1
gpgcheck=0
[xget-appstream]
name=Xget Rocky Linux AppStream
baseurl=https://xget.xi-xu.me/rocky/$releasever/AppStream/$basearch/os/
enabled=1
gpgcheck=0
更新和安装
# 更新包列表
sudo dnf makecache
# 安装包
sudo dnf install nginx
openSUSE
配置 zypper 使用 Xget
# 添加仓库
sudo zypper ar -f https://xget.xi-xu.me/opensuse/tumbleweed/repo/oss xget-oss
# 刷新仓库
sudo zypper refresh
更新和安装
# 更新包列表
sudo zypper refresh
# 安装包
sudo zypper install nginx
# 下载包文件
sudo zypper download nginx
Arch Linux
配置 pacman 使用 Xget
编辑 /etc/pacman.conf:
[xget]
Server = https://xget.xi-xu.me/arch/$repo/os/$arch
更新和安装
# 更新包列表
sudo pacman -Sy
# 安装包
sudo pacman -S nginx
# 下载包文件
sudo pacman -Sw nginx
其他平台
arXiv
下载论文
# 下载 PDF
wget https://xget.xi-xu.me/arxiv/pdf/2312.12345.pdf
# 下载源码
wget https://xget.xi-xu.me/arxiv/e-print/2312.12345
F-Droid
下载应用
# 下载 APK
wget https://xget.xi-xu.me/fdroid/repo/com.example.app_100.apk
# 配置 F-Droid 客户端
# 在 F-Droid 客户端中添加仓库:https://xget.xi-xu.me/fdroid/repo
Jenkins 插件
下载插件
# 下载插件
wget https://xget.xi-xu.me/jenkins/latest/git.hpi
# 配置 Jenkins 使用 Xget
# 在 Jenkins 系统配置中设置更新站点:https://xget.xi-xu.me/jenkins/update-center.json
Apache 软件下载
下载软件
# 下载软件
wget https://xget.xi-xu.me/apache/tomcat/tomcat-10/v10.1.15/bin/apache-tomcat-10.1.15.tar.gz
# 使用 aria2c 多线程下载
aria2c -x 16 -s 16 https://xget.xi-xu.me/apache/tomcat/tomcat-10/v10.1.15/bin/apache-tomcat-10.1.15.tar.gz
容器注册表
配置 Docker 使用 Xget
编辑 /etc/docker/daemon.json:
{
"registry-mirrors": [
"https://xget.xi-xu.me/cr/registry-1.docker.io"
]
}
重启 Docker:
sudo systemctl restart docker
拉取镜像
# 拉取镜像
docker pull nginx:latest
# 拉取特定标签
docker pull nginx:1.25
# 拉取私有镜像
docker pull ghcr.io/user/image:tag
使用 Podman
# 配置 Podman 使用 Xget
podman pull docker.io/nginx:latest
# 拉取镜像
podman pull nginx:latest
AI 推理提供商
配置 OpenAI 使用 Xget
# 使用 curl
curl https://xget.xi-xu.me/ip/api.openai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Python 代码示例
import openai
# 配置使用 Xget
openai.api_base = "https://xget.xi-xu.me/ip/api.openai.com/v1"
openai.api_key = "YOUR_API_KEY"
# 发送请求
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[{"role": "user", "content": "Hello!"}]
)
配置 Anthropic 使用 Xget
import anthropic
# 配置使用 Xget
client = anthropic.Anthropic(
api_key="YOUR_API_KEY",
base_url="https://xget.xi-xu.me/ip/api.anthropic.com"
)
# 发送请求
message = client.messages.create(
model="claude-3-opus-20240229",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}]
)
下载工具
wget
基本使用
# 下载文件
wget https://xget.xi-xu.me/gh/microsoft/vscode/archive/main.zip
# 指定输出文件名
wget -O vscode.zip https://xget.xi-xu.me/gh/microsoft/vscode/archive/main.zip
# 断点续传
wget -c https://xget.xi-xu.me/gh/microsoft/vscode/archive/main.zip
cURL
基本使用
# 下载文件
curl -o vscode.zip https://xget.xi-xu.me/gh/microsoft/vscode/archive/main.zip
# 显示进度条
curl -# -o vscode.zip https://xget.xi-xu.me/gh/microsoft/vscode/archive/main.zip
# 断点续传
curl -C - -o vscode.zip https://xget.xi-xu.me/gh/microsoft/vscode/archive/main.zip
aria2
多线程下载
# 16 线程下载
aria2c -x 16 -s 16 https://xget.xi-xu.me/gh/microsoft/vscode/archive/main.zip
# 批量下载
aria2c -i urls.txt
# 断点续传
aria2c -c https://xget.xi-xu.me/gh/microsoft/vscode/archive/main.zip
IDM (Internet Download Manager)
使用方法
- 复制加速 URL
- IDM 会自动捕获下载
- 或手动添加到 IDM
配置
- 在 IDM 设置中配置最大连接数
- 启用分段下载
- 配置下载速度限制
CI/CD 集成
GitHub Actions
配置示例
name: Build and Test
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://xget.xi-xu.me/npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Test
run: npm test
GitLab CI
配置示例
image: node:20
variables:
NPM_CONFIG_REGISTRY: "https://xget.xi-xu.me/npm"
before_script:
- npm ci
stages:
- build
- test
build:
stage: build
script:
- npm run build
test:
stage: test
script:
- npm test
常见问题
Q1: 如何验证 Xget 是否正常工作?
A: 下载一个小文件并检查速度:
time wget https://xget.xi-xu.me/gh/microsoft/vscode/archive/main.zip
Q2: 如何切换回原始源?
A: 恢复原始配置:
# npm
npm config set registry https://registry.npmjs.org
# pip
pip install --index-url https://pypi.org requests
# apt
sudo sed -i 's/xget.xi-xu.me/deb.debian.org/g' /etc/apt/sources.list
Q3: Xget 支持哪些协议?
A: Xget 支持 HTTP/HTTPS、Git、Docker、AI 推理等多种协议。
Q4: 如何提高下载速度?
A: 使用多线程下载工具:
aria2c -x 16 -s 16 URL
Q5: Xget 会缓存文件吗?
A: 是的,Xget 使用 Cloudflare Cache API 进行边缘缓存,默认缓存时长为 30 分钟。
总结
Xget 为 40+ 开发者常用平台提供了统一的加速服务。通过简单的 URL 转换或配置更改,即可享受极速下载体验。无论是代码托管、包管理、容器镜像还是 AI 模型,Xget 都能提供稳定、高效的加速服务。