How can I clone a private GitLab repository?

时间:2015-05-12 22:38:38

标签: git github gitlab

When I do this:

"4 kW"

I am getting this error:

fatal: HTTP request failed

When I use SSH:

git clone https://example.com/root/test.git

I am getting this error:

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

It's a private repository, and I have added my SSH keys.

6 个答案:

答案 0 :(得分:24)

You have your ssh var res = xmlhttp.responseText.split(";"); document.getElementById("meow").value=res[1]; statement wrong: clone

That statement would try to clone a repository named git clone username git@example.com:root/test.git into the location relative to your current path, username.

You want to leave out git@example.com:root/test.git:

username

答案 1 :(得分:23)

If you're trying this with GitHub, you can do this with your SSH entered:

SELECT name, population, area
FROM world 
WHERE (area > 3000000 OR population > 250000000)
AND name NOT IN ('United states', 'China') 
AND NOT (area > 3000000 AND population > 250000000)

答案 2 :(得分:16)

对于有关GitLab的基于HTTPS的克隆,似乎不是一个简单的解决方案。因此,如果您需要基于SSH的克隆,则应考虑以下三个步骤:

  • 使用您用于注册的电子邮件正确创建SSH密钥。我会使用默认文件名来键入Windows。别忘了提供密码!

    $ 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个人资料中设置> SSH密钥>密钥

  • 获取本地连接:

    $ 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.
    

最后,克隆任何私有或内部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.

答案 3 :(得分:0)

在做之前

git clone https://example.com/root/test.git

确保已在系统中添加了ssh密钥。请遵循:https://gitlab.com/profile/keys

添加后,运行上面的命令。它将提示您输入gitlab用户名和密码,并在身份验证时被克隆。

答案 4 :(得分:0)

您可能需要~/.ssh/config

Host gitlab.YOURDOMAIN.DOMAIN
    Port 1111
    IdentityFile ~/.ssh/id_rsa

,然后您可以使用git clone git@DOMAINandREPOSITORY。这意味着您始终使用用户git

答案 5 :(得分:0)

如果您使用的是Windows,

  1. 创建一个文件夹,然后从那里打开git bash

  2. git bash中的

    git clone git@gitlab.com:示例/projectName.git