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吧。

相关推荐
unsynchronized1 小时前
OpenClaw 安装指南:Linux 与 Windows 系统详细教程
linux·运维·windows·ai
x***r1512 小时前
R语言 4.5.1安装教程 Windows版:解压+管理员运行+自定义路径+启动验证指南
windows
m0_694845573 小时前
Oh My Zsh 使用指南:Zsh 终端配置与插件管理教程
服务器·前端·小程序·开源·github
米小虾4 小时前
hackerbot-claw 攻击事件深度解析:AI Agent 时代的安全警钟
github·ai编程
非凡ghost4 小时前
Zen Browser:基于 Firefox 的极简开源浏览器,隐私与速度兼得
前端·网络·windows·学习·开源·firefox·软件需求
木梓辛铭4 小时前
windows下部署openclaw详细方法及错误处理办法
windows·学习方法·持续部署
John_ToDebug4 小时前
死锁案例:UI 线程阻塞等待跨进程 COM 注入
c++·windows·笔记
逛逛GitHub5 小时前
AI 搜索利器 MiroThinker 发布新模型!我接入小龙虾,太实用了。
github
happyprince6 小时前
2026年03月18日热门Model/github项目
github
无限进步_7 小时前
深入解析list:一个完整的C++双向链表实现
开发语言·c++·git·链表·github·list·visual studio