macOS配置GitHub和GitLab共存
- 查看之前是否设置过全局的
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
- 注:
若
git commit
提示:*** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository.
执行:
git config user.email "abc@qq.com“
git config user.name "abc“
posted on 2020-10-12 13:55 GaiheiluKamei 阅读(259) 评论(0) 编辑 收藏 举报