macOS配置GitHub和GitLab共存

时间:2020-10-12 20:29:10   收藏:0   阅读:28
  1. 查看之前是否设置过全局的user.nameuser.email:

git config --global --list

  1. 如果已设置,则删除

git config --global --unset user.name "你的名字"
git config --global --unset user.email "你的邮箱"

  1. 生成SSH Key:

ssh-keygen -t rsa -f ~/.ssh/id_rsa.github -C "abc@qq.com"
ssh-keygen -t rsa -f ~/.ssh/id_rsa.gitlab -C "abcdef@qq.com"

  1. 获取公钥粘贴到对应平台:

cat id_rsa.github.pub
cat id_rsa.gitlab.pub

  1. 配置config:

cd ~/.ssh && touch config
vim config

# github
Host github.com
HostName github.com
User GaiheiluKamei
IdentityFile ~/.ssh/id_rsa.github

# gitlab
Host gitlab.google.com  ## 公司提供的网址
HostName gitlab.google.com ## 同上
User git
IdentityFile ~/.ssh/id_rsa.gitlab
Port 2223  ## 公司提供的端口
  1. 验证是否正确:

ssh -T git@github.com
ssh -T gitlab.google.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!