/ Zhaoyun's Blog / git 配置备忘

git 配置备忘

2018-03-16 posted in [技术]

配置多帐户

1、建立新的ssh-key:

ssh-keygen -t rsa - C “email@address.com”

name可以随便指定,密码用空也没问题

2、添加新的ssh-key

3、配置 .ssh/config

# Default github user(first@mail.com)
Host github.corp
    HostName github.com
    User git
    IdentityFile ~/.ssh/github_rsa

# second user(second@mail.com)
Host github.person
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_person_rsa

4、使用config中定义的host,如

git remote add origin github.person:hezhaoyun/servlet-demo.git
…
git clone github.person:hezhaoyun/servlet-demo.git