切换github帐号

bash 复制代码
#!/bin/bash

# Get the current GitHub user
current_user=$(git config --global user.name)

if [ "$current_user" == "user1" ]; then
    # Switch to user2
    mv id_rsa id_rsa_user1
    mv id_rsa.pub id_rsa_user1.pub
    mv id_rsa_user2 id_rsa
    mv id_rsa_user2.pub id_rsa.pub

    # Configure Git for user2
    git config --global user.name "user2"
    git config --global user.email "user2@gmail.com"
    echo "Switched to user2"
else
    # Switch to user1
    mv id_rsa id_rsa_user2
    mv id_rsa.pub id_rsa_user2.pub
    mv id_rsa_user1 id_rsa  
    mv id_rsa_user1.pub id_rsa.pub

    # Configure Git for user1
    git config --global user.name "user1"
    git config --global user.email "user1@gmail.com"
    echo "Switched to user1"
fi

# Display the current user name and email
echo "Current GitHub user: $(git config --global user.name)"
echo "Current GitHub email: $(git config --global user.email)"
相关推荐
semantist@语校9 小时前
第五十一篇|构建日本语言学校数据模型:埼玉国际学院的城市结构与行为变量分析
java·大数据·数据库·人工智能·百度·ai·github
一个儒雅随和的男子9 小时前
Web开发身份认证技术解析
前端·github
CoderJia程序员甲10 小时前
GitHub 热榜项目 - 日榜(2025-11-29)
ai·开源·大模型·github·ai教程
草梅友仁11 小时前
Nano Banana Pro AI 图像生成模型与创意实践 | 2025 年第 48 周草梅周报
开源·github·aigc
前端伪大叔19 小时前
第29篇:99% 的量化新手死在挂单上:Freqtrade 隐藏技能揭秘
后端·python·github
摇滚侠1 天前
零基础小白自学 Git_Github 教程,发现工具寻找灵感,笔记04
笔记·github
无限进步_2 天前
C语言数组元素删除算法详解:从基础实现到性能优化
c语言·开发语言·windows·git·算法·github·visual studio
天外飞雨2 天前
把代码提交到github
github
happyCoder2 天前
VS Code Git 神器:内置功能与GitLens插件使用技巧
git·github
lkbhua莱克瓦242 天前
集合进阶8——Stream流
java·开发语言·笔记·github·stream流·学习方法·集合