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

相关推荐
sthnyph10 分钟前
MySQL 8.0在windows环境安装及配置
windows·mysql·adb
逛逛GitHub33 分钟前
断网也能跑的小龙虾,EdgeClaw 在 GitHub 上开源了。
github
深念Y1 小时前
Windows 11 23H2 搜狗输入法卸载后任务栏严重卡顿问题分析
windows
Uncertainty!!1 小时前
将docker镜像上传到github镜像存储仓库(GitHub 容器仓库(GHCR)使用流程)
docker·容器·github
AI-小柒3 小时前
DataEyes 聚合平台 + Claude Code Max 编程实战
android·开发语言·人工智能·windows·python·macos·adb
赵文宇(温玉)3 小时前
Openclaw-In-Docker新版本发布,更轻、更快、更健壮,1600+次下载,30+Github关注
docker·容器·github·小龙虾·clawclaw
CoderJia程序员甲3 小时前
GitHub 热榜项目 - 日榜(2026-03-23)
ai·大模型·llm·github·ai教程
luyun0202024 小时前
Word题库转换,吾爱出品
windows·word·figma
badhope4 小时前
Docker入门到实战全攻略
linux·python·docker·github·matplotlib
mygljx4 小时前
Redis 下载与安装 教程 windows版
数据库·windows·redis