当我这样做:
git clone https://example.com/root/test.git
我收到此错误:
致命:HTTP请求失败
当我使用SSH时:
git clone username [email protected]:root/test.git
我收到此错误:
/server/user/[email protected]:root/test.git/.git/中初始化的空Git存储库 致命:'user'似乎不是git存储库 致命:远程端意外挂断
它是一个私有存储库,我添加了SSH密钥。
你的ssh clone
声明错了:git clone username [email protected]:root/test.git
该语句将尝试将名为username
的存储库克隆到相对于当前路径[email protected]:root/test.git
的位置。
你想省略username
:
git clone [email protected]:root/test.git
如果您正在使用GitHub尝试此操作,则可以使用您输入的SSH执行此操作:
git clone https://[email protected]/username/repository
对于GitLab,基于HTTPS的克隆似乎没有直接的解决方案。因此,如果您需要基于SSH的克隆,则应考虑以下三个步骤:
$ ssh-keygen -t rsa -C "[email protected]" -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 [email protected]
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.
在做之前
git clone https://example.com/root/test.git
确保在系统中添加了ssh密钥。请关注:https://gitlab.com/profile/keys。
添加后运行上面的命令。它将提示您的gitlab用户名和密码,并且在身份验证时,它将被克隆。