前言
一般情况下,我们都是一台电脑配置一个Git账号,使用如下命令:
git config --global user.name "your name"
git config --global user.email "your email"
我的电脑上已经配置GitHub的,现需要配置公司的 GitLab 账号(或者其他类型的 Git 账号)。
配置多个git账号
清除原有全局设置
该步骤非必须的,如果你没有设置过全局用户名、email 等信息,则不用清除原有设置
- 取消全局设置
git config --global --unset user.name
git config --global --unset user.email
生成ssh密钥
- 生成github 对应账号的ssh密钥
ssh-keygen -t rsa -C "[email protected]"
- 执行完上面的命令后,命令行会弹出以下提示
Enter file in which to save the key (/c/Users/admin/.ssh/id_rsa):
- 在此处修改id_rsa文件名(注意:不要覆盖之前的rsa密钥)
/c/Users/admin/.ssh/i