切换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)"
相关推荐
码流怪侠2 小时前
【GitHub】WorldMonitor:一个工程极致主义的实时全球情报仪表盘深度解析
github
北极糊的狐6 小时前
20.3 使用 Vercel CLI 手动部署(无需 GitHub,适合不常更新的项目)
github
2401_853448237 小时前
Git安装流程和基础使用步骤
git·github
官乐7 小时前
Github创建上传仓库流程
github
tokenKe8 小时前
Buzz:蜂巢意识协作平台|Agent 不是 Bot,而是持有独立密钥对的团队成员|SSP Github Daily
github
zdkdchao9 小时前
建立gitee对github仓库的镜像
gitee·github
小弥儿10 小时前
GitHub 今日热榜 | 2026-07-24:金融 K 线基础模型上榜
学习·金融·开源·github
FII工业富联科技服务12 小时前
灯塔用例解析:AI服务器柔性自动化制造体系的四大核心能力
github
lazy H13 小时前
从入门到日常开发,一篇文章掌握 Git 核心操作
git·后端·学习·github
zzqssliu21 小时前
煤炉自动代拍系统的队列设计与超时控制机制
git·github