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

相关推荐
love530love2 小时前
【ComfyUI】解决 ModuleNotFoundError: No module named ‘inference_core_nodes‘ 问题
人工智能·windows·python·comfyui·inference-core
Bruce_Liuxiaowei4 小时前
Windows系统安全加固——从基础到进阶的实战配置
windows·安全·系统安全
Zzz 小生5 小时前
LangChain Streaming-Overview:流式处理使用完全指南
人工智能·python·语言模型·langchain·github
RZcKUXIhvPR6 小时前
基于VSG控制(虚拟同步发电机控制)的模块化多电平变流器MM C 通过设置可编程电源,模拟电网...
windows
电饭叔8 小时前
python转换字符串介绍
开发语言·windows·python
winfield82110 小时前
Win11系统,如何让Sublime直接显示在右键点击中?
windows·编辑器·sublime text
winfield82111 小时前
Windows 的 cmd 里如何定义 alias?
windows
小恰学逆向11 小时前
【实用工具趣谈】美化你的终端——你的终端也可以如此炫酷
windows
ITHAOGE1512 小时前
下载 | Win10正式版最新系统ISO映像 (22H2、19045.6937、多合一版本)-修复系统问题
windows·科技·microsoft·微软·电脑
用户5798547697112 小时前
04:工具系统设计:从抽象基类到 JSON Schema 的完整实现
github