在git項目上新建了一個項目,但是里面沒有任何代碼文件,這時候如果使用http地址去克隆則會報錯废麻,報錯顯示英文翻譯大體為找不到基礎(chǔ)文件。
百度查了下模庐,沒有相關(guān)的烛愧,后面克隆了其他的新項目發(fā)現(xiàn)可以,綜合起來覺得應該是因為git項目上沒有東西可克隆,所以報錯怜姿。然后就去嘗試加了ssh的密鑰慎冤,之后克隆就ok了。底下是生成ssh公私鑰的命令沧卢。轉(zhuǎn)載自: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):
// 設(shè)置輸入密碼
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上設(shè)置 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 了