在 Debian 上更换 GitLab 软件源(APT 源),通常是指把 GitLab 官方的软件仓库换成 国内镜像源,以加快安装和更新速度。下面按常见场景说明。
GitLab 官方源地址一般是:
https://packages.gitlab.com/gitlab/
在国内访问可能较慢,因此可以换成 清华 TUNA 镜像。
cat /etc/apt/sources.list.d/gitlab*.list
如果看到类似:
deb https://packages.gitlab.com/gitlab/gitlab-ce/debian/ bullseye main
说明是官方源。
以 Debian 11(bullseye) 为例(其他版本替换 bullseye 即可):
sudo sed -i \
's|https://packages.gitlab.com/gitlab/gitlab-ce|https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce|g' \
/etc/apt/sources.list.d/gitlab_gitlab-ce.list
✅ 常用 Debian 版本对应关系:
| Debian 版本 | 代号 |
|---|---|
| Debian 12 | bookworm |
| Debian 11 | bullseye |
| Debian 10 | buster |
sudo apt update
sudo apt update
sudo apt install -y curl openssh-server ca-certificates
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/gitlab-ce.gpg
echo "deb [signed-by=/usr/share/keyrings/gitlab-ce.gpg] \
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/debian $(lsb_release -cs) main" \
| sudo tee /etc/apt/sources.list.d/gitlab-ce.list
然后:
sudo apt update
sudo apt install gitlab-ce
将 gitlab-ce 改为 gitlab-ee 即可:
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/debian
apt-cache policy gitlab-ce
✅ 正确做法:
只修改 /etc/apt/sources.list.d/gitlab*.list
不要修改 /etc/apt/sources.list
✅ 推荐方案:
Debian + GitLab → 使用 清华大学 GitLab CE 镜像
如果你愿意,可以告诉我:
我可以给你一条 完全适配你环境的命令。