macOS配置GitHub和GitLab共存
时间:2020-10-12 20:29:10
收藏:0
阅读:28
- 查看之前是否设置过全局的
user.name
和user.email
:
git config --global --list
- 如果已设置,则删除:
git config --global --unset user.name "你的名字"
git config --global --unset user.email "你的邮箱"
- 生成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"
- 获取公钥粘贴到对应平台:
cat id_rsa.github.pub
cat id_rsa.gitlab.pub
- 配置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 ## 公司提供的端口
- 验证是否正确:
ssh -T git@github.com
ssh -T gitlab.google.com
评论(0)