(003)git 多账户配置
git-ssh 多账户配置
·
1.查看配置
git config --list
2.移除全局配置
- 移除全局配置
git config --global --unset user.name
- 查看全局用户名
git config --global user.name
- 移除全局配置邮箱
git config --global --unset user.email
- 查看全局邮箱
git config --global --user.emial
- 移除全局密码
git config --global --unset user.password
- 查看全局密码
git config --global user.password
3.针对每个添加的用户
生成公钥文件
ssh-keygen -t rsa -C 422615924@qq.com
-t: 要生成的密钥类型-c:识别密钥的注释
配置
git config --global user.name username
git config --global user.email useremail
在存放公钥文件和私钥的文件的路径下建立对应的目录,在步骤三,指定对应的生成文件存放的目录。或者在生成密钥文件的时候,指定名字
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa): lvpeilin
假如这里的配置文件根路径为 ~/.ssh
- 在 ~/.ssh/ 新建名字为 config 文本文件(没有后缀名),编辑内容:
# config 配置1
Host gitlab.dy-space.com
HostName 129.204.27.214
Port 2284
IdentityFile .\.ssh\id_rsa
PreferredAuthentications publickey
User 422615924@qq.com
# config 配置2
Host gitlab.dy-space_2.com
HostName 129.204.27.214
Port 2284
IdentityFile .\.ssh\id_rsa
PreferredAuthentications publickey
User 422615924@qq.com
假如仓库的地址为:git@gitlab.dy-space.com:fc/nowheregun.git, Host 匹配 gitlab.dy-space.com,走配置1。
Host: 配置的别名HostName: 填写该Git账号的官网地址IdentityFile: 私钥文件PreferredAuthentications: 认证方式User: 用户名
5.在对应的 Github 添加对应生成的公钥 pub.
更多推荐
所有评论(0)