github多账号管理
同一个电脑管理多个不同的github账号
1.生成公钥、私钥,配置config (详细创建过程点击查看 )生成key时需要将key存放在不同路径或者不同名称
- ssh config示例
1
2
3
4
5
6
7
8
9
10
11
12
13
14~/.ssh/config
#### 配置1
Host host1
HostName github.com
User git
Port 22
IdentityFile ~/.ssh/id_rsa
#### 配置2
Host host2
HostName github.com
User git
Port 22
IdentityFile ~/.ssh/id_rsa_xxx
2.两种
1.本地已存在、已创建或者clone到本地
第一种方法,修改项目下的 .git/config
1
2
3[remote "origin"]
url = git@host2:username/repo.git
fetch = +refs/heads/*:refs/remotes/origin/*第二种方法使用命令修改
1
2git remote rm origin
git remote add origin git@host2:username/repo.git
2.clone仓库时对应配置的host名称
1 | git clone git@host2:username/repo.git |
如有侵权行为,请点击这里联系我删除