切换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)"
相关推荐
阿里嘎多学长18 分钟前
2025-12-10 GitHub 热点项目精选
开发语言·程序员·github·代码托管
浪子sunny1 小时前
量化指标之RSI公式验证
github
shandianchengzi1 小时前
【记录】Github|Github账号意外被封以及不需要手机号解封的全过程(被封原因:一台设备上登录过多个账号)
github·gemini
AllinGold2 小时前
Centos stream9 安装docker并配置镜像源 实现github docker项目部署
docker·centos·github
CoderJia程序员甲14 小时前
GitHub 热榜项目 - 日榜(2025-12-9)
ai·开源·大模型·github·ai教程
知行力15 小时前
【GitHub每日速递 20251209】Next.js融合AI,让draw.io图表创建、修改、可视化全靠自然语言!
javascript·人工智能·github
徐小夕16 小时前
知识库创业复盘:从闭源到开源,这3个教训价值百万
前端·javascript·github
jiaoxingk17 小时前
如何丢弃本地修改并恢复为 GitHub 最新版本
github
im_AMBER19 小时前
github pages 配置踩坑
笔记·学习·github
猫头虎20 小时前
openEuler异构算力体系下的GPU加速性能测试与优化研究
开源·github·aigc·ai编程·ai写作·gpu算力·华为snap