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

相关推荐
鹓于5 小时前
手机SSH直连电脑运行iflow终极安全配置
windows·安全·ssh
Jackey_Song_Odd6 小时前
Part 1:Python语言核心 - 序列与容器
开发语言·windows·python
浪潮IT馆8 小时前
Windows 达梦 8(DM8)数据库完整安装教程 + 命令行导入 .dmp 文件完整指南
数据库·windows
NeilNiu8 小时前
Windows系统本地安装OpenClaw+飞书机器人
windows·机器人·飞书
mldlds10 小时前
mysql9.0windows安装
windows·adb
未佩妥剑,已入江湖11 小时前
docker Windows下安装
运维·windows·docker·容器
徐小夕11 小时前
借助AI,1周,0后端成本,我开源了一款Office预览SDK
前端·vue.js·github
CoderJia程序员甲11 小时前
GitHub 热榜项目 - 日榜(2026-03-18)
ai·大模型·llm·github·ai教程
似水明俊德12 小时前
10-C#
开发语言·windows·c#
逛逛GitHub12 小时前
硅谷大佬把自己 Claude Code 武器库给开源了,1 周就 2 万点赞。
github