mac系统下:git
经过以下步骤可成功切换到新帐号:shell
git config --global user.name 查看当前用户名
git config --global user.email 查看当前邮箱
git config --global user.name "Your Name" 切换用户为您的用户名
git config --global user.email you@example.com 切换邮箱为您的git邮箱
复制代码
cd ~/.ssh
复制代码
$ ssh-keygen -t rsa -C “你的邮箱”//注意C必定要大写
复制代码
按3个回车,不设密码bash
文件存放位置 ~/.sshdom
若是是window的话就在:C:\Users\Administrator.ssh 下面ssh
若是是mac,在执行指令的目录(如mac打包机为:/User/zxl01/.ssh下)ide
Your identification has been saved in id_rsa. // 私钥
Your public key has been saved in id_rsa.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]-----+
复制代码
打开公钥,复制公钥粘贴到 gitlab上设置 ssh Key 的地方gitlab
cat id_rsa.pub
复制代码
打开gitlab-->点击Profile Settings,而后: spa
LELEdeMacBook-Pro:.ssh lele$ ssh-add id_rsa // 添加私钥
Enter passphrase for id_rsa: // 若是前面没有设密码,就不会有这个
Identity added: id_rsa (id_rsa) //出现这个,说明你成功设置了
复制代码
注意:一段时间后,若是出现提交或拉取代码失败,需从新在终端添加私钥便可.net