Windows下Git配置Gitlab和Github双账户

Git Bash 生成密钥

Github

ssh-keygen -t rsa -f ~/.ssh/id_rsa_github -C "GithubAccount"

Gitlab

ssh-keygen -t rsa -f ~/.ssh/id_rsa_gitlab -C "GitlabAccount"

注意:GithubAccount/GitlabAccount 分别换成自己的github和gitab账户

修改配置文件

touch ~/.ssh/config
vim ~/.ssh/config

config写入以下内容,配置用户名和SSH私钥路径

#GitHub
Host github.com
HostName github.com
User GithubAccount
IdentityFile ~/.ssh/id_rsa_github

#GitLab
Host gitlab.com
HostName gitlab.com
User GitlabAccount
IdentityFile ~/.ssh/id_rsa_gitlab

注意:User分别换成自己的github和gitab账户

分别在Github和Gitlab添加SSH公钥

over !

你可能感兴趣的:(GitHub,git,github,gitlab)