当前位置: 首页 > news >正文

同一台主机两个github账号切换使用

同一主机两个github账号切换使用

可能某些原因,我们需要在公司与个人之间切换相关的开发者账号。如同一台主机两个github账号

此为windows环境
操作步骤如下

首先,创建2组 公私钥

默认用户目录 ~/.ssh

$ ssh-keygen -t ed25519 -C "your_email_1@example.com"
Enter file in which to save the key (~/.ssh/id_ed25519):
# 回车, 默认生成 id_ed25519 和 id_ed25519.pub$ ssh-keygen -t ed25519 -C "your_email_1@example.com"
Enter file in which to save the key (~/.ssh/id_ed25519):
# 录入 id_ed25519_sec, 生成 id_ed25519_sec 和 id_ed25519_sec.pub

其次,生成一个新文件 ~\.ssh\config

假设两个github账号分别为

commentusernameemail
github-oneoneAcconeAcc@aa.cc
github-sectesterutesteru@xx.cc
# Default account (first account)
Host github-oneHostName github.comPreferredAuthentications publickeyUser gitIdentityFile ~/.ssh/id_ed25519IdentitiesOnly yes# Second account
Host github-secHostName github.comPreferredAuthentications publickeyUser gitIdentityFile ~/.ssh/id_ed25519_secIdentitiesOnly yes

再次,将生成的公钥分别放入不同的github账号中

github > settings -> keys -> Access -> SSH and GPG keys -> New SSH key

最后测试

假设 second account 账号实际为 testeru, 且有一个repository 为abc

$ git clone git@github-sec:testeru/abc.git

备注

代码修改提交(可能会失败),如失败,设置当前目录下的用户为

$ git config user.name testeru
$ git config user.email testeru@xx.cc

http://www.mrgr.cn/news/8714.html

相关文章:

  • Zookeeper的watch机制是如何工作的?
  • flink+flinkcdc+同步(MYSQL到MYSQL)实践
  • AudioNotes -将音频内容转 markdown
  • redis | 认识非关系型数据库Redis的列表类型及python如何操作redis
  • SpringBoot集成kafka-指定topic(主题)-partition(分区)-offset(偏移量)消费信息
  • 如何利用ThinkPHP6打造高效SEO优化的网站!
  • R 语言学习教程,从入门到精通,R XML 文件使用(19)
  • 【单片机】PICC编译器和XC8编译器的历史发展,有什么关系
  • fpga图像处理实战-闭运算
  • 初识C语言指针(5)
  • 巨省成本的电子版招生简章越来越流行,你知道是怎么制作的吗?
  • Java | Leetcode Java题解之第367题有效的完全平方数
  • 第六届土木工程、环境资源与能源材料国际学术会议(CCESEM 2024,10月18-20)
  • Linux网络基础
  • GAP技术:实现隔离网络之间安全数据交换的创新方案
  • JVM-Java的四种引用
  • 基于springmvc实现文件上传
  • 【Linux篇】Linux的用户和权限
  • JUC- Synchronized原理
  • 深度学习100问2-分布式假设在自然语言处理中的应用场景有哪些