当我这样做时:
git clone https://example.com/root/test.git
我收到这个错误:
fatal: HTTP request failed
当我使用 SSH 时:
git clone username git@example.com:root/test.git
我收到这个错误:
Initialized empty Git repository in /server/user/git@example.com:root/test.git/.git/
fatal: 'user' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
这是一个私有(private)存储库,我已经添加了我的 SSH key 。
最佳答案
对于 GitLab 基于 HTTPS 的克隆,似乎没有直接的解决方案。因此,如果您想要基于 SSH 的克隆,您应该考虑接下来的三个步骤:
使用您用于注册的电子邮件正确创建 SSH key 。我会使用默认文件名来键入 Windows。别忘了输入密码! (提示:如果您已经有一个 ssh key ,则可以跳过此步骤)
$ ssh-keygen -t rsa -C "your.email@example.com" -b 4096 Generating public/private rsa key pair. Enter file in which to save the key ($PWD/.ssh/id_rsa): [\n] Enter passphrase (empty for no passphrase):[your password] Enter same passphrase again: [your password] Your identification has been saved in $PWD/.ssh/id_rsa. Your public key has been saved in $PWD/.ssh/id_rsa.pub.
将最近生成的
id_rsa.pub
中的所有内容复制并粘贴到您的 GitLab 配置文件中的 Setting>SSH keys>Key 中。# Copy to clipboard pbcopy < ~/.ssh/id_rsa.pub
在本地建立联系:
$ ssh -i $PWD/.ssh/id_rsa git@gitlab.com Enter passphrase for key "$PWD/.ssh/id_rsa": [your password] PTY allocation request failed on channel 0 Welcome to GitLab, you! Connection to gitlab.com closed.
最后,克隆任何私有(private)或内部 GitLab 存储库!
$ git clone https://git.metabarcoding.org/obitools/ROBIBarcodes.git
Cloning into 'ROBIBarcodes'...
remote: Counting objects: 69, done.
remote: Compressing objects: 100% (65/65), done.
remote: Total 69 (delta 14), reused 0 (delta 0)
Unpacking objects: 100% (69/69), done.
关于git - 如何克隆私有(private) GitLab 存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30202642/