Please enable Javascript to view the contents

多github 账号 配置管理设置

 ·  ☕ 1 分钟  ·  ✍️ CheeseMocha

从下面的github 页面拷贝过来的,尝试后可以正常工作。

https://gist.github.com/jexchan/2351996

多ssh 账号配置


首先创建不同的 public key

create different ssh key according the article Mac Set-Up Git

1
	$ ssh-keygen -t rsa -C "your_email@youremail.com"

Please refer to github ssh issues for common problems.

两个用户的例子。

1
2
	~/.ssh/id_rsa_activehacker
	~/.ssh/id_rsa_jexchan

生成两个 账号的key 后,用ssh-add 添加两个账号:

1
2
	$ ssh-add ~/.ssh/id_rsa_activehacker
	$ ssh-add ~/.ssh/id_rsa_jexchan

这个是删除,暂时不用这个,后面需要再用。

1
	$ ssh-add -D

列出所有key

1
	$ ssh-add -l

最后需要添加一个配置文件把2个key对应的域名配置进去

1
2
3
    $ cd ~/.ssh/
	$ touch config
	$ subl -a config

添加配置

#activehacker account
Host github.com-activehacker
	HostName github.com
	User git
	IdentityFile ~/.ssh/id_rsa_activehacker

#jexchan account
Host github.com-jexchan
	HostName github.com
	User git
	IdentityFile ~/.ssh/id_rsa_jexchan

然后根据拉下来的repo ,配置下邮箱。单个git 的配置单个邮件和用户名
不然容易发给无效用户名去仓库

clone your repo
git clone git@github.com:activehacker/gfs.git gfs_jexchan

这个是单个repo 下面单独设置

1
2
3
4
5
	$ git config user.name "jexchan"
	$ git config user.email "jexchan@gmail.com" 
 
	$ git config user.name "activehacker"
	$ git config user.email "jexlab@gmail.com" 

这个是全局设置

1
2
$ git config --global user.name "jexchan"
$ git config --global user.email "jexchan@gmail.com"

测试ok

1
2
3
4
5


	$ git add .
	$ git commit -m "your comments"
	$ git push

分享

cheesemocha