在 Linux 下使用 GitLab 导入项目,通常有以下几种常见方式。你可以根据项目来源选择适合的方法。
git@gitlab.com:username/myproject.git
或
https://gitlab.com/username/myproject.git
cd /path/to/your/project
git init
git remote add origin git@gitlab.com:username/myproject.git
git add .
git commit -m "Initial commit"
git branch -M main
git push -u origin main
如果使用 HTTPS,会提示输入 GitLab 用户名和密码(或 Personal Access Token)
git clone --mirror https://github.com/user/repo.git
cd repo.git
git push --mirror git@gitlab.com:username/repo.git
cd project
git init
git add .
git commit -m "Import project"
git remote add origin git@gitlab.com:username/project.git
git push -u origin main
如果是你自己搭建的 GitLab:
http://your-server-ipssh-keygen -t ed25519
cat ~/.ssh/id_ed25519.pub
把公钥添加到 GitLab → Settings → SSH Keys
使用 Personal Access Token 代替密码
git branch -M main
如果你能说明:
我可以给你更精确的步骤。