在git项目上新建了一个项目,但是里面没有任何代码文件,这时候如果使用http地址去克隆则会报错,报错显示英文翻译大体为找不到基础文件。
百度查了下,没有相关的,后面克隆了其他的新项目发现可以,综合起来觉得应该是因为git项目上没有东西可克隆,所以报错。然后就去尝试加了ssh的密钥,之后克隆就ok了。底下是生成ssh公私钥的命令。转载自:http://www.knowsky.com/985273.html
1 在普通用户 进入 .ssh 文件.(.ssh 文件生成百度很多) cd .ssh/
LELEdeMacBook-PRo:~ lele$ cd .ssh/
LELEdeMacBook-Pro:.ssh lele$ ls
known_hosts
LELEdeMacBook-Pro:.ssh lele$ man ssh-add
LELEdeMacBook-Pro:.ssh lele$
LELEdeMacBook-Pro:.ssh lele$ ssh-keygen -t rsa -C "your email"
// 你的邮箱
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/lele/.ssh/id_rsa): id_rsa1 // 给生成私钥命名(直接回车默认id_rsa)
Enter passphrase (empty for no passphrase):
// 设置输入密码
Enter same passphrase again:
Your identification has been saved in id_rsa1.
// 私钥
Your public key has been saved in id_rsa1.pub.
// 公钥
The key fingerprint is:
SHA256:IL6L2NjBQDAAuYfD6NzTbR8VIc/fJl1coDUhzL3LYP8 leyu@chargedot.com
The key's randomart image is:
+---[RSA 2048]----+
|B. . +o.=o.|
|o. +.o+.o.|
|o+ . . oo .o|
|*... . . .+ + .|
|+o. o . S .. * = |
| = o o o . * |
| o o . . . . |
| = o . . E|
|o + . |
+----[SHA256]-----+
LELEdeMacBook-Pro:.ssh lele$ ls // 查看生成文件
id_rsa id_rsa1
id_rsa1.pub known_hosts
LELEdeMacBook-Pro:.ssh lele$ cat id_rsa1.pub
// 打开公钥 复制公钥粘贴到 gitlab上设置 sshKey 的地方(可百度)
ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAABAQDIRPiN+aEeJ4ZAYshiKdDSv9tHovvmKCIai8uUc8RqxYo5BPJwN5NLH5FVKgIO12uj4PZl4q/QpXh9oaPVKJLZWTGh7aZc2lBmqS8CDLnFAniFnhYb5CABg+gQyFv71857UeV4QaO6sPas6jYFyeMgguEylzFUVz2dxsjonoGnPxA14YxG0k1bvkuQT1MEuwcyN17vOZYPOyh5xBfTJMYrqp3V875ju508SUgE+oFYXoJF/bMoUXPH+9D7YSTTqbocv55Su7z95/LMhp5RNX4MwMxJF9LdcLwTWvXuPucB6RbsRLqf9hy53/boLyphgc0UKpHNgPZTnCYRKJ8+hwrL
leyu@chargedot.com
LELEdeMacBook-Pro:.ssh lele$ ls
id_rsa id_rsa1
id_rsa1.pub known_hosts
LELEdeMacBook-Pro:.ssh lele$ ssh-add id_rsa1 // 添加私钥
Enter passphrase for id_rsa1:
Identity added: id_rsa1 (id_rsa1)
LELEdeMacBook-Pro:.ssh lele$
至此 sshKey 配置完成,打开 source tree 克隆代码就 OK 了