本地使用 GitHub 以及 Gitee

本文详细介绍了如何清除原有的Git全局配置,生成并管理SSH密钥,将私钥添加到SSH agent,配置SSH config文件,并将SSH密钥添加到GitHub和Gitee,以便进行多账户管理。通过这些步骤,可以安全地在不同的Git平台上使用不同的身份进行操作。
摘要由CSDN通过智能技术生成

1.1 清除原有 git 的全局配置

$ git config --global --list

image-20220220204533366

$ git config --global --unset user.name "chenlan"
$ git config --global --unset user.email "739904595@qq.com"

1.2 生成 ssh keys

$ ssh-keygen -t rsa -f ~/.ssh/id_rsa.github -C "739904595@qq.com"
$ ssh-keygen -t rsa -f ~/.ssh/id_rsa.gitee -C "739904595@qq.com"

image-20220220220856

1.3 将私钥添加到 ssh agent 中

$ ssh-agent bash
$ ssh-add ~/.ssh/id_rsa.github
$ ssh-add ~/.ssh/id_rsa.gitee

1.4 配置 config 文件

$ touch ~/.ssh/config

image-20220220220019828

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

# gitee
Host gitee.com
HostName gitee.com
User chenlan
IdentityFile ~/.ssh/id_rsa.gitee

1.5 添加 ssh key

// 复制对应的公钥配置到 github 和 gitee 上
Setting -> SSH and GPG keys -> NEW SSH key

image-20220220231055226

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值