配置多个git账号
使用git管理代码时,往往公司和个人的代码对应不同的git仓库,或者同时在多个代码托管平台托管代码
对不同的账号使用不同的ssh-key
不同的github账号对应不同的ssh-key(具体生成key的过程以及github配置略)
在ssh根目录新建config文件
```py
#Default GitHub
Host github.com # 这个可以自己定义
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
# 第二个配置
Host github-as #这是别名,区别第一个(会多次使用)
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_as #(这里是新的key)
```
测试 ssh -T github-as
对仓库进行用户名和邮箱设置
`git config --global--unset user.name`
`git config --global--unset user.email`
`git config user.name "name"`
`git config user.email "email"`
对仓库进行url重置
git remote set-url origin github-as:username/jib.git