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

相关推荐
coding消烦员2 小时前
在 Windows 内网搭建 Git 仓库:共享普通仓库 vs 中心 bare 仓库
windows·git
想用offer打牌4 小时前
一站式讲清Spring AI Alibaba的OverAllState和RunnableConfig
人工智能·架构·github
xiaoliuliu123456 小时前
IE8-WindowsXP-x86-CHS_23253_BDdl.exe 安装步骤(XP 32位简体中文版)
windows
百事牛科技6 小时前
文件不想再加密了?取消Word 打开密码的方法
windows·word
逛逛GitHub7 小时前
推荐 5 个小众但有趣的 GitHub 开源项目。
github
极智-9967 小时前
GitHub 热榜项目 · 日榜精选(2026-01-07) | protobuf、web-check、PowerToys等
github·开发工具·开源项目·数据交互·ai框架
love530love8 小时前
EPGF 新手教程 13在 PyCharm(中文版 GUI)中创建 Hatch 项目环境,并把 Hatch 做成“项目自包含”(工具本地化为必做环节)
开发语言·ide·人工智能·windows·python·pycharm·hatch
峰上踏雪8 小时前
Go(Golang)Windows 环境配置关键点总结
开发语言·windows·golang·go语言
Tfly__9 小时前
Ubuntu20.04安装Genesis(最新)
linux·人工智能·pytorch·ubuntu·github·无人机·强化学习
lusasky9 小时前
在Windows上编译、安装Rust
开发语言·windows·rust