lepton 2020-07-04
新安装 git 跳过。
若之前对 git 设置过全局的 user.name 和 user.email。
类似 (用 git config --global --list 进行查看你是否设置)
$ git config --global user.name "你的名字" $ git config --global user.email "你的邮箱"
必须删除该设置
$ git config --global --unset user.name "你的名字" $ git config --global --unset user.email "你的邮箱"
1:先配置github
生成一个github用的SSH-Key密钥:输入命令:(id_rsa_github是生成公钥的名)
在指定的 .ssh 目录下 运行
ssh-keygen -t rsa -C ""
或者
$ ssh-keygen -t rsa -C ‘你的邮箱‘ -f ~/.ssh/id_rsa_github

2:配置gitee
生成一个gitee用的SSH-Key密钥:输入命令:(id_rsa_gitee是生成公钥的名)
在指定的 .ssh 目录下 运行
ssh-keygen -t rsa -C ""
直接回车3下,什么也不要输入,就是默认没有密码。
3:查看公钥 添加到对应账号下的
命令:
cat id_rsa_github.pub

需要在.ssh文件夹下新建config文件,先新建config.txt,然后修改文件名去掉后缀。
config文件内容如下:
其中第二行和第三中 需要填写gitlab的仓库地址
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitee
User 账号邮箱
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
User 账号邮箱
————————————————
# 配置文件参数
# Host : Host可以看作是一个你要识别的模式,对识别的模式,进行配置对应的的主机名和ssh文件
# HostName : 要登录主机的主机名
# User : 登录名
# IdentityFile : 指明上面User对应的identityFile路径$ ssh -T
