下面从使用场景、部署方式、配置位置、权限模型、CI/CD、网络访问等角度,系统对比 GitHub 和 自建 Linux GitLab(GitLab CE/EE) 的配置区别。
| 对比项 | GitHub | Linux GitLab |
|---|---|---|
| 提供方 | GitHub(Microsoft) | 自己部署在 Linux 服务器 |
| 使用方式 | SaaS | 私有化部署 |
| 控制程度 | 低(平台限制) | 高(完全可控) |
| 适合场景 | 开源 / 公共项目 | 企业内部 / 私有代码 |
无需 Linux 环境
# Omnibus 安装示例
sudo apt install gitlab-ee
sudo gitlab-ctl reconfigure
配置文件:
/etc/gitlab/gitlab.rb
git remote add origin https://github.com/username/repo.git
git remote add origin https://gitlab.example.com/username/repo.git
或 SSH:
git@gitlab.example.com:username/repo.git
~/.ssh/id_rsa.pub| 项目 | GitHub | GitLab |
|---|---|---|
| 添加位置 | Web → Settings → SSH | Web → Preferences → SSH |
| 域名 | github.com | 自定义域名 |
# gitlab.rb 示例
gitlab_rails['gitlab_default_can_create_group'] = true
.github/workflows/ci.yml
.gitlab-ci.yml
Linux GitLab 还可配置 Runner:
gitlab-runner register
ufw allow 443
gitlab-rake gitlab:backup:create
GitHub 是“用平台”,Linux GitLab 是“管平台”
如果你愿意,我可以:
你更关心哪一块?