切换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)"
相关推荐
QC七哥42 分钟前
伪造git提交记录生成点阵字符
git·github
TimberWill1 小时前
GitHub Copilot 一键生成中文commit提示语规则设置
git·github
徐小夕2 小时前
pxcharts 多维表格开源!一款专为开发者和数据分析师打造的轻量化智能表格
前端·架构·github
NocoBase3 小时前
GitHub 上星星数量前 10 的 AI CRM 开源项目
人工智能·低代码·开源·github·无代码
CoderJia程序员甲4 小时前
GitHub 热榜项目 - 日榜(2025-12-22)
ai·开源·大模型·github·ai教程
cnnews5 小时前
某讯T1刷armbian
linux·ubuntu·开源·github
bj_zhb5 小时前
git reflog用法
大数据·linux·git·github
GoGeekBaird14 小时前
Andrej Karpathy:2025年大模型发展总结
后端·github
CoderJia程序员甲15 小时前
GitHub 热榜项目 - 日榜(2025-12-21)
开源·大模型·llm·github·ai教程