切换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)"
相关推荐
miofly2 小时前
GitHub 今日推荐|DiPlay:让 iPhone CarPlay 直连 BYD 车机,无需硬件适配器
开源·github
行者-全栈开发2 小时前
【前端/JS框架】CVE-2026-3854:GitHub Enterprise Server X-Stat注入XSS漏洞深度剖析与紧急修复指南
前端·javascript·github
怕浪猫4 小时前
2026年9月面18个后端
后端·面试·github
掘金018 小时前
Cursor Agent Prompt 拆解
人工智能·程序员·github
樱花落木兰9 小时前
SpringBoot + ECharts 后台数据统计报表模块实战
java·javascript·spring boot·ai·log4j·github·echarts
Gu0Qiang12 小时前
从 0 到 1 打造 AI 提示流编排器:别把大模型当机械拼图!Case #7 字段冻结陷阱与代码回滚复盘(开源系列 15)
人工智能·github
u13013012 小时前
GitHub 热榜项目:日榜(2026-09-29)
github
用户8371332007612 小时前
AI 写的发布流程 CI 全绿,为什么仍没通过需求验收?
ci/cd·github
SL_staff12 小时前
JVS-Rules vs Drools:金融风控团队为何转向业务可编辑的决策平台
java·spring cloud·github