Git 使用技巧 02 多个ssh_key的生成与使用 - mitudegaoyang/kuaiyijian GitHub Wiki
git config --global user.name "Your Name"
git config --global user.email "Your Email Address"
ssh-keygen -t rsa -C "Your Email Address"
Ps.ssh-keygen -t rsa -C "[email protected]"
ssh-keygen -t rsa -C “Your Email Address” -f 'Your Name'
Ps.ssh-keygen -t rsa -C “[email protected]” -f 'gaotianyangHM'
(此时会在.ssh下生成gaotianyangHM & gaotianyangHM.pub)
ssh-keygen -t rsa -C "Your Email Address"
Enter file in which to save the key (/c/Users/Lenovo/.ssh/id_rsa):'Your Name'
Ps.Enter file in which to save the key (/c/Users/Lenovo/.ssh/id_rsa):'gaotianyangHM'
(此时同样会在.ssh下生成gaotianyangHM & gaotianyangHM.pub)
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Host my.github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/my
Ps.Host名字随意,接下来会用到
ssh -T [email protected]
ssh -T [email protected]
Ps.如果出现Hi xxx!You've successfully authenticated 就说明连接成功了
打开.Git/config文件
#更改[remote "origin"]项中的url中的
#my.github.com 对应上面配置的host
[remote "origin"]
url = [email protected]:itmyline/blog.git
或者在Git Bash中提交的时候修改remote
$ git remote rm origin
$ git remote add origin [email protected]:itmyline/blog.git
#my.github.com对应一个账号
git clone [email protected]:username/repo.git
Ps.git clone [email protected]:username/repo.git
Ps.git clone [email protected]:username/repo.git