Github多账号共存

在开发阶段,如果同时拥有多个开源代码托管平台的账户,在代码的管理上非常麻烦。那么,如果同一台机器上需要配置多个账户,怎样才能确保不冲突,不同账户独立下载独立提交呢?

我们以两个github账号进行演示

1.ssh工具生成对称密钥

bash 复制代码
ssh-keygen -t rsa -C "xxxxxxx@qq.com" -f "id_rsa_one"
ssh-keygen -t rsa -C "yyyyyyy@qq.com" -f "id_rsa_two"

2.github添加ssh公钥

将生成的公钥(pub)内容分别复制到github对于位置

3.本地保存秘钥文件

把生成的4个文件放到ssh默认目录(C盘)

4.配置ssh文件

新建config文件(不要文件类型)

参数说明

host:主机名称,可随意取名,不要重复即可(相当于hostName的别称)

hostName:gitee.com或github.com或其他

User:github账号名字或者邮箱均可

IdentityFile:ssh生成的私钥文件路径

5.ssh脚本测试

6.clone远程仓库

clone的时候选择ssh方式

7.github账号配置

取消git 全局账号配置

bash 复制代码
git config --global --unset user.name
git config --global --unset user.email

采用本地账号配置

bash 复制代码
git config --local user.name xxx
git config --local user.email yyy@qq.com

clone远程仓库(使用host别称)

bash 复制代码
git clone git@one:kingston-csj/jforgame.git

好了,开始coding吧。

相关推荐
微八度1 小时前
.Net Web API应用部署成windows服务
windows·.net·web api·winddows服务
脆皮瞎1 小时前
openclaw本地部署(windows)
windows·ai·openclaw
Norach5 小时前
ubuntu22.04安装ssh-server与realvnc-server
linux·服务器·经验分享·ubuntu·ssh·vnc
小云小白6 小时前
windows Wsl2 搭建rockyLinux podman 容器开发环境
windows·podman·wsl2
铁甲前沿6 小时前
一个月玩转MQTT(篇四:移远EC200U模块MQTT连接测试)
mqtt·github·emqx·mqttx·移远ec200u
凯子坚持 c6 小时前
在 openJiuwen 里把在线小工具搬回本地
人工智能·windows·stable diffusion·openteledb·openclaw
百事牛科技9 小时前
不用装软件也能解压?WinRAR自解压功能介绍
windows·winrar
此刻觐神9 小时前
Windows学习笔记-18(MFC项目-制作快捷方式管理工具)
windows·笔记·学习·mfc
水饺编程10 小时前
Windows 编程基础:wsprintf 函数
c语言·c++·windows·visual studio