mac配置两个github账号使用

编程

场景:公司自带的GitHub,我个人在gitee上的账号,所以需要用两个账号,因为我需要看到我自己用账号的提交记录,不喜欢用公司账号。

1、配置第二个github账号

假设已配置了一个github账号

$ git config --global user.name "昵称"

$ git config --global user.email "邮箱"

2、生成密钥

$ ssh-keygen -t rsa -C "邮箱"

3、设置名称

不要与第一个github账号名称重复,关键,下面默认名是:id_ras,所以你第一个账号默认是id_rsa

$ Enter file in which to save the key (/Users/Administrator/.ssh/id_rsa): id_rsa_cj

4、新密要添加到SSH agent

$ ssh-agent bash

$ ssh-add ~/.ssh/id_rsa_cj

5、进入ssh创建配置文件

$ cd ~/.ssh

$ touch config

6、关联你使用的两个git

vim config

进入,如下我的配置

Host github.com

HostName http://git.ceb520.com/

IdentityFile ~/.ssh/id_rsa

Host gitee

HostName https://gitee.com/

IdentityFile ~/.ssh/id_rsa_cj

7、分别测试

都能看到两个github上,两个不同账号的提交记录

以上是 mac配置两个github账号使用 的全部内容, 来源链接: utcz.com/z/517437.html

回到顶部